Skip to content
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

[ECP-9376] Fix checkout for configurable products when product is in low stock #62

Merged
merged 7 commits into from
Nov 8, 2024

Conversation

pmarjan-onestic
Copy link
Contributor

@pmarjan-onestic pmarjan-onestic commented Oct 7, 2024

Summary

For configurable products, shoppers can now select a shipping method and complete checkout when the product is in low stock.

In the compatibility module, there are two calls to CartItemPersister, which processes BuyRequestData differently each time:

  • First Call: BuyRequestData is returned as a float (indicating, possibly, a single unit or specific quantity).
  • Second Call: BuyRequestData is returned as an object (indicating a detailed configuration request, such as specific product options or custom data).

When BuyRequestData is treated as an object in the second request, Magento’s Quote.php interprets this as a full update request for the cart. It tries to add more of the product to the cart and exceeds the available stock, which triggers an out-of-stock exception.

This PR introduces the CompositeConfigProvider that includes all necessary configuration providers and avoids unnecessary processing that may interfere with cart items or stock levels.

Tested scenarios

When checking out with a configurable product:

  • It is possible to change the country
  • It is possible to select a shipping method
  • Successful checkout with the limited quantity in stock

Fixes #59

@candemiralp
Copy link
Member

Hello @pmarjan-onestic,

Thank you for providing the fix. Is this PR ready to be reviewed? If so, could you please add a brief description about the fix and how these changes lead us to the solution?

Best Regards,
Can

@pmarjan-onestic
Copy link
Contributor Author

pmarjan-onestic commented Oct 21, 2024

hi @candemiralp

Adyen\Hyva\Model\Configuration is a configuration reader that previously used to depend on Magento\Checkout\Model\CompositeConfigProvider. This composite provider comes with all sorts of config providers, and one of them (sorry, but cannot remember which) would just do extra work that would turn the buyRequest for the update item from an array into some data object....

Marc's suggestion was something like: _"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."

And the PR is now following this idea, practically introducing "Adyen\Hyva\Model\CompositeConfigProvider" instead of "Magento\Checkout\Model\CompositeConfigProvider". The former is custom configured in di.xml to include config provider that are relevant to the adyen usage, making it more targeted and probably more preformance oriented at the same time.

Let me know please if any questions.

@candemiralp
Copy link
Member

Hello @pmarjan-onestic,

Thank you for providing a fix for this issue. We are still testing it and this PR will be merged after testing.

Best Regards,
Can

@khushboo-singhvi khushboo-singhvi changed the title #59 Configuration provider Issue Preventing Checkout with Configurable Products in Low Stock Oct 28, 2024
Copy link

@ArjenMiedema ArjenMiedema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like the approach of the custom ConfigProvider. I'm having the issue you mentioned as well. Will check if that is solved with this PR. Would be really awesome to get this working properly.

Copy link

sonarcloud bot commented Nov 6, 2024

@candemiralp candemiralp merged commit 11e6f49 into develop Nov 8, 2024
4 checks passed
@candemiralp candemiralp deleted the issue-59-config-provider branch November 8, 2024 08:19
@candemiralp candemiralp changed the title Issue Preventing Checkout with Configurable Products in Low Stock [ECP-9376] Issue Preventing Checkout with Configurable Products in Low Stock Nov 8, 2024
@candemiralp candemiralp mentioned this pull request Nov 18, 2024
@candemiralp candemiralp added the Fix Indicates a bug fix label Nov 18, 2024
@sena1482 sena1482 changed the title [ECP-9376] Issue Preventing Checkout with Configurable Products in Low Stock [ECP-9376] Fix checkout for configurable products when product is in low stock Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fix Indicates a bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue Preventing Checkout with Configurable Products in Low Stock
6 participants