checkout / checkout-magento2-plugin

Checkout.com Magento 2 official extension
MIT License
32 stars 33 forks source link

double quantity error in cart #486

Open mounirsemaan1 opened 3 years ago

mounirsemaan1 commented 3 years ago

Using a fresh clean Magento 2.3.6 setup:

The line https://github.com/checkout/checkout-magento2-plugin/blob/0bdd058e6c348995693fd4222c310d4b8ab51b06/Model/Ui/ConfigProvider.php#L97 is causing

"The requested qty is not available " on the cart page

to reproduce: 1- Setup a fresh Magento 2.3.6 2- Add a configurable product with a simple configuration product with Quantity 1 3- Make sure that in the inventory settings you don't allow back orders "No backorder" 4- Add the product to the cart 5- Navigate to the cart page checkout/cart/

explanation: 1- When navigating to the cart page the ConfigProvider is initiated and it triggers the code L97 $this->quoteHandler->saveQuote(); 2- This is causing the quote to be saved but at some point, it is recreated and it is calling function updateItem($itemId, $buyRequest, $params = null) in Magento\Quote\Model\Quote which is instead of setting quantity it is adding 1 to the quantity so it becomes 2 , which gives the error.

3- if you allow backorders it then fixes itself by resetting it to 1, but if it is disabled it throws an exception on line 1697 and it doesn't continue the process

JamesFX2 commented 2 years ago

Yeah, found the same issue. Basically, don't save the quote twice.

Dnd-Gimix commented 2 years ago

Hello @mounirsemaan1 @JamesFX2 ,

Thank you both for your feedback.

We have fixed this issue in the latest 3.0.1 version of the extension. Can you update your extension and confirm that it is now OK?

Many thanks. Regards,