Skip to content

Out of stock items can still be bought when inside an active order #1738

@kyunal

Description

@kyunal

Describe the bug
It's possible to buy items that are out of stock if they were added to the cart (added to an active order) before they went out of stock.

To Reproduce
Steps to reproduce the behavior:

  1. Consider User A, User B and Item C with a quantity of 20
  2. User A puts 5 items in their cart
  3. User B puts 20 items in his their and checks out
  4. After the items have been bought and the stock is depleted, User A can still check out and buy the things in their cart
  5. Saleable stock is negative and the item was oversold

Expected behavior
The shop API should refuse the purchasing of the items and throw an error, forcing User A to take action and to adjust their cart

Environment (please complete the following information):

  • @vendure/core version: 1.6.5
  • Nodejs version: 16 LTS
  • Database (mysql/postgres etc): postgres
  • Inventory tracking through vendure is enabled

Additional context
Other variations are possible, e.g. User B does not need to buy the entire stock, just enough so that whatever User B will buy is not fully available anymore.

A potential workaround was discussed through the implementation of a CustomOrderProcess that uses the onTransitionStart hook to check stock levels before the order changes state to ArrangingPayment.

Metadata

Metadata

Labels

P4: lowNon-critical, workarounds existdesign 📐This issue deals with high-level design of a featuretype: bug 🐛Something isn't working

Type

No type

Projects

Status

📅 Planned

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions