Commerce Module Tuesday: Commerce Stock

Commerce Stock is a great demonstration of how Drupal Commerce can be extended with great Drupal 7 features. It adds an integer field for "stock" to a product, and then manages that using rules.

To use Commerce Stock, just enable the module and then visit admin/commerce/config/stock to configure which product types it should be configured for. At this point, a stock field will be added to your products and you can set the initial stock value.

Now, whenever a product is checked out, the stock level will be decremented, and if it reaches zero, the add-to-cart button will be disabled.

Some details:

  • You can change when stock is decremented by using your own rule instead of the default rule. The default rule decrements stock "when completing the checkout process" but you might want to do it when an order is complete or when it is shipped.
  • Commerce Stock currently does not currently attempt to deal with purchase collisions (two customers purchasing the same product at the same time).
  • Version 7.x-1.x is not transactional, and does not have a log of when or why the stock was changed, but 7.x-2.x promises new capabilities (see the project page).
  • You can easily add the stock field to any view of products you use to see current stock levels.

Here's the screencast:

Posted December 24, 2011

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <p> <br>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
X
In 2019 Commerce Guys rebranded to Centarro.

Change is at the center of eCommerce, but our team and mission remain the same.

Our consulting, development, and support offerings apply our expertise to help you adapt to change and grow.

Find us now at: https://www.centarro.io