Commerce Stock Reserve module flow chart

This module extends Commerce Stock to allow "reserving" a product's stock when a customer adds it to their shopping cart. This removes the risk of overselling when multiple customers are attempting to buy the same product at the same time.

The trade-off is that there is a risk of underselling, if stock remains reserved in customers' carts when sales are closed. So this module lets you release old reserved stock during cron runs. The default is that reserved stock will be released from carts that have not been modified for more than half an hour. You can configure this behaviour at admin/commerce/config/stock/reserve.

In Drupal 7, you can also use this module alongside Commerce Cart Expiration , which deletes entire carts after a configured period of inactivity. This functionality is built in to Commerce for Drupal 8.

Warning: scope of this module

This module only deals with reserving stock. It does not check or validate stock levels, and it does not decrement stock levels on purchase.

For the simplest solution in Drupal 7, use this module alongside Commerce Simple Stock and Commerce Simple Stock Rules (commerce_ss and commerce_ssr, both submodules of Commerce Stock), and leave all the default rules enabled.

Drupal 8/9 version

The Drupal 8/9 version is a preliminary dev version and should not be used on production sites without extensive testing.

It currently works by creating a stock transaction to reduce stock when it is added to the cart, and then creating a stock transaction to restore this once the order is placed, deleted or cancelled. Note that this means it could trigger events related to stock numbers, e.g. if you have events running when stock hits zero, or when stock is added to a product with zero stock (e.g. Commerce Stock Notifications). Suggestions for suppressing these events, or an alternative way of reserving stock, are welcome.

Credits

Drupal 7 original version developed by Patrick Dawkins at UCLU, the students' union for University College London.

Drupal 8/9 version developed by Maxwell Keeble, also at UCLU (now Students' Union UCL).

Project information

Releases