-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue Preventing Checkout with Configurable Products in Low Stock #59
Comments
hi @mbernabeu thanks for the comment and the nice details that give a good head start. Also thank you for this suggestions "Since the configuration is only needed for filling the data in the payment block, it might be enough to just fetch the specific configuration that is needed in these blocks and not fetch all the configurations." I am thinking though that this configuration is needed in a situation when we have a one step hyva checkout enabled, in which case it is possible to select a payment method before anything else is done with the checkout including selecting the shipping method. This is probably the reason behind the current implementation. I have a feeling that the important thing to clarify is why would the
Of course, I will add posts with any updates that I might run into. |
Draft solution is added. |
Describe the bug
Bug When One Product in Stock. No order can be placed. After investigating the issue, it's observed that no problems occur with MSI + Adyen or with Hyva theme + MSI. However, the issue arises when the compatibility module is involved. Specifically, when attempting to add a configurable product with limited stock (e.g., 2 items), the shipping methods do not appear on the checkout page. Interestingly, if the pre-selected shipping method is not changed, the issue does not occur.
In the code, two calls are made to CartItemPersister to collect
BuyRequestData
using the line:$buyRequestData = $this->cartItemOptionProcessor->getBuyRequest($productType, $item);
This
BuyRequestData
can either be a float value or an object. In the first request, it's a float, so no exception is thrown. However, in the second request, it becomes an object. When the system proceeds to update the quote item with the following logic:if (is_object($buyRequestData)) { /** Update item product options */ if ($quote->getIsActive()) { $item = $quote->updateItem($itemId, $buyRequestData); } }
While updating the quote item, the logic in Quote.php tries to add more products to the quote, same amount as already added to the cart. Since there are no additional items available in stock, this triggers an exception.
$resultItem = $this->addProduct($product, $buyRequest);
My observation is that since the configuration is only needed to populate data in the payment block, it may be sufficient to fetch only the specific configurations required for those blocks, rather than retrieving all configurations.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Actual behavior
Magento version
2.4.7
Plugin version
1.1.0
Additional context
The text was updated successfully, but these errors were encountered: