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

Spree::Order::InsufficientStock error raised when confirming an order #3020

Closed
spaghetticode opened this issue Jan 4, 2019 · 1 comment
Closed
Labels
type:bug Error, flaw or fault

Comments

@spaghetticode
Copy link
Member

Steps to reproduce

See this gist for integration tests that expose the issue. Specifically the last spec is failing.

When two users try to purchase the last item remaining from a non-backordeable stock location at the same time then the last one will experience an unhandled error Spree::Order::InsufficientStock. This happens only if there is a second backorderable stock location for the product.

The error is generated by this line in Spree::Order model:

before_transition to: :complete, do: :validate_line_item_availability

So, controller validations (provided here via before_action :ensure_sufficient_stock_lines) are following a different path, calling different methods, and this causes that error to be raised later in the order finalization process. Unifying the process seems to me the most reasonable way to fix the issue.

As a side note, but I think this is quite relevant, if the customer restarts the checkout process at least from the delivery step then the error does not happen anymore, as the order shipments are recreated from scratch this time using the backorderable stock location.

Expected behavior

IMHO the customer should be redirected to the checkout delivery page, showing them an error message that suggests to restart the checkout process due to some changes in product availabilities.

Actual behavior

When the customer presses the order confirmation button then checkout process is halted by Spree::Order::InsufficientStock. The customer experiences a 500 server error page.

System configuration

Solidus Version:

master and previous versions, at least down to 2.6.x

Extensions in use:

none

@kennyadsl
Copy link
Member

Closed with #3023, thanks @spaghetticode !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Error, flaw or fault
Projects
None yet
Development

No branches or pull requests

3 participants