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

Fix Spree::Order::InsufficientStock error raised when confirming an order #3035

Conversation

rubenochiavone
Copy link
Contributor

Description

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.

Fix

Improved Spree::Order.insufficient_stock_lines method to also map @order.line_items that are not validated using Spree::Stock::AvailabilityValidator.

Tests

Added tests from @spaghetticode's gist. Had to improve on it since now validation prevents user to advance to next checkout page.

Closes #3020.

Checklist:

  • Pull Request guidelines are respected
  • Changes are covered by tests (if possible)
  • Each commit has a meaningful message attached that described WHAT changed, and WHY

…rder

Improve Spree::Order.insufficient_stock_lines method to also map
@order.line_items that are not validated using
Spree::Stock::AvailabilityValidator.
@rubenochiavone
Copy link
Contributor Author

Didn't saw #3023 😄 since it was not linked with issue

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

Successfully merging this pull request may close these issues.

None yet

2 participants