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

Changing quantity in cart > stock #117

Open
msj121 opened this issue Jul 18, 2023 · 2 comments
Open

Changing quantity in cart > stock #117

msj121 opened this issue Jul 18, 2023 · 2 comments

Comments

@msj121
Copy link
Contributor

msj121 commented Jul 18, 2023

I have a current issue where if you change the quantity in cart > then the stock available the item disappears from cart. Refreshing I get the maximum available. ie: I select "8" but only have "5", when I refresh I find "5" but in the meantime it disappears and doesn't let me "add to cart" (insufficient stock).

Desired solution: perhaps allow a dropdown which matches number of stock? or textfield? or at least min(stock,8) of options?

Perhaps a textfield with arrow buttons? Not sure what the correct approach is here, ideas?

@gioboa
Copy link
Collaborator

gioboa commented Jul 19, 2023

Thanks for your feedback. @prasmalla is it your vendure plugin?

@michaelbromley
Copy link
Member

When the GraphQL mutation adjustOrderLine is executed, and the quantity exceeds the available stock, an ErrorResult will be returned. So this line will be incorrectly asserting the result to be of type Order, when it will be actually of type OrderLimitError (docs).

The proper way to handle this is that for any mutation that returns a union which may include ErrorResults, the storefront needs to check the type, and in the case of an error, handle appropriately such as displaying an error message.

More docs on this here: https://docs.vendure.io/developer-guide/error-handling/#expected-errors-errorresults

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants