code4business / freeproduct2

Magento2 extension that allows creating sales rules that add gift products.
64 stars 28 forks source link

Gift item added and removed correctly but when placed order then automatically gift item qty getting double! #7

Closed iindranil closed 5 years ago

iindranil commented 6 years ago

I am using the 1.0.4 version where gift item added perfectly when I added main product. and removed gift product perfectly when I removed main product.

But when I placed order then gift product qty getting double automatically.

I am using Magento ver. 2.2.3.

Can you guys please have a look into this issue thank you,

domeglic commented 6 years ago

That is strange, version 4 was exactly a fix for that bug. We will look into it.

iindranil commented 6 years ago

Thank you for your quick response @domeglic

Also, I noticed that It's not working based on Cart Price Rules setup.

For example, I need this kind of feature where If customer added 1 qty "Main product" then 1 qty "Gift product" will be added automatically which is fine but If customer added "Main Product" 2 qty then "Gift product" not added 2 qty.

I am confused that is it not working ? or extension doesn't support this feature? or have I configured something wrong?

Thanks in advance!

domeglic commented 6 years ago

This is not supported because that only works if the cart rule condition is specified as "when main product in cart". However if the cart rule would be for example "subtotal 100€ or more" then we could not apply the same logic.

We might add this option in the future.

iindranil commented 6 years ago

Thanks for your confirmation, @domeglic

Any idea about the above issue I mentioned? Why gift item getting double after placed order which is fine until click on the placed order button?

Is there any quick solutions which I can fix because it's running on the live server?

iindranil commented 6 years ago

Any update on that issue?

Thanks!

domeglic commented 6 years ago

I could not reproduce the issue on Magento v2.2.3 (or v2.2.5) with the module version v1.0.4. Are there any other extensions that change checkout or totals calculation?

cgsoratto commented 6 years ago

I had the same problem! The only solution I found was having to change the file "/vendor/magento/module-quote/Model/Quote/Item/ToOrderItem.php" (of course, creating a module for the override).

Before the "return" of the "convert()" function add your code.

An example:

  $productGift = ['SKU1', 'SK2', 'SK3'];
         if (in_array($ item->getProduct()->getSku(), $productGift)) {
             $orderItem->setQtyOrdered(QTD);
         }

Bye!

achtdreizehn commented 6 years ago

issue with double qty successfully fixed with 1.0.4 (from 1.0.3)

PiroozMB commented 6 years ago

The issue is still there when the invoice printed you see the free product ordered as double. not solved yet.

PiroozMB commented 6 years ago

@cgsoratto thank you so much for your solution. It worked

Zalm commented 6 years ago

Hello, i have the same problem, i've just changed the cgsoratto's patch like :

if($orderItem->getData('product_type')=="freeproduct_gift"){
            $orderItem->setQtyOrdered(1);
        }

No need to insert the SKU, only the free products will be set to qty = 1.

Is there any update ?

Thank you,

domeglic commented 6 years ago

I could not reproduce it on the latest version, but I will do more testing and see if I can.

domeglic commented 5 years ago

Unfortunately I still cannot reproduce this bug. I tried it on Magento v2.2.6 and v2.3 with the latest freeproduct 1.2.0 and I always get only 1 gift item in order and invoice/pdf.

Unless there is new information about steps to reproduce the bug then I am closing this issue for now. bug_7_not_reproduced