-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Unable to execute addSimpleProduct mutation while other items out of stock #26683
Comments
Thanks for opening this issue! |
Hi @logaretm. Thank you for your report.
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
For more details, please, review the Magento Contributor Assistant documentation. @logaretm do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?
|
@magento give me 2.4-develop instance |
Hi @logaretm. Thank you for your request. I'm working on Magento 2.4-develop instance for you |
Hi @logaretm, here is your Magento instance. |
Thanks for opening this issue! |
Hi @engcom-Bravo. Thank you for working on this issue.
|
Overcome this issue by overriding Cart model adding line below to remove error during process.
|
Thanks for opening this issue! |
✅ Confirmed by @engcom-Bravo Issue Available: @engcom-Bravo, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself. |
Hi @AleksLi. Thank you for working on this issue.
|
This is a complex task that requires framework changes. Removing errors is not an option. It leads to the wrong flow when user will see cart errors only on place order step. Errors should be returned under |
Hi @cpartica. Thank you for working on this issue.
|
Hi @nrkapoor. Thank you for working on this issue.
|
Hi @logaretm. Thank you for your report.
The fix will be available with the upcoming 2.4.0 release. |
Summary (*)
We are using Magento as a headless backend for our front-facing application, we are using the GraphQL API to build the frontend.
We noticed if we added a product to cart, and that product later became out of stock, any further attempts to add items to cart will fail with
Some cart items are out of stock
effectively locking up the cart from adding other items or changing other items quantities.This is the returned GraphQL error:
This is a breaking issue for us, as the alternative would result in a very poor experience for our users.
Currently, we have things set up that the frontend is able to detect whenever this exception is thrown and tries to amend it by removing the offending items and attempting to re-play whatever mutations are done to the cart since then.
Needless to say, this is a very flaky solution and it doesn't make sense to have this restriction in the first place since the REST API seems to be fine with this scenario.
Examples (*)
To Reproduce:
I have successfully reproduced this on a fresh magento environment
Proposed solution
Ideally, the GraphQL API should allow mutating the cart as long as the out-of-stock item is not being the target of the mutation (updating its quantity for example).
A slightly less robust solution is to allow the mutation to go through, but return
errors
alongside thedata
prompting the GQL client to update their UI and also be aware of possible problems.GraphQL requests for reproducing
Create an empty cart
Add product to cart
The text was updated successfully, but these errors were encountered: