Commerce Stock module, for Drupal Commerce.
This module provides stock management for Drupal Commerce stores.
Commerce Stock - version 2
This version is a complete rewrite of the code in version one and is more flexible, has more features and is the one to use for new sites.
The module uses rules for implementation of the stock checking and allows for more flexibility, it also uses an API submodules architecture allowing the extension of the functionality.
The module currently implements a sub module 'simple stock' providing most of the features in version 1 out of the box.
To implement your own business logic: install the modules and configure the rules.
Key Features of V2
- A rule and action for enabling and disabling the add to cart form.
- A rule and action for validating stock for the add to cart button action.
- A rule for checking the cart form submit, also used for checkout submit and review submit.
- A new checkout pane placed in the first step of checkout: stops the user from accessing checkout if order contains out of stock items
- Supports Decimal stock.
- Works with Inline Entity Form module.
- Advance configuration of the add to cart button action for even more control
- Commerce Stock field formatter for converting stock levels into text messages.
Installation and setup
1. Download commerce_stock
2. Enable the Commerce Stock API, Commerce Simple Stock, and Commerce Simple Stock Rules modules.
3. Go to Home » Administration » Store » Configuration » Stock management
4. Select the “simple stock management” tab
5. Check the product types you want simple stock to manage and hit submit
Important: you may need to clear caches after installing and enabling stock for your products!
add to cart validation
The add to cart is now checked using rules: Event "Check if a product is in stock"
It passes in the Product, Requested Quantity, the Quantity already in the cart & the total requested (Requested+ already in cart)
The action "Set the result of a stock check" allows you to set the following
block transaction - block adding to cart and display a message to the user
display message only - allows adding to cart and display a message to the user
Message: the message to display to the user
Approved Quantity: the quantity to add to the cart, allows you to approve 1 if 3 where asked for and two already in cart.
Advanced configuration of the add to cart form
This action will allow us to do much more then just disable the add to cart.
- Convert the add to cart button to a custom link
- Replace the add to cart button with user defined HTML
- Override the forms validation and submit functions
- Disable the quantity box if active
- Added Prefix and Suffix to the submit element
Commerce decimal quantities: http://drupal.org/project/commerce_decimal_quantities
Expend functionality using rules Issues
- Increase stock when order is canceled
- Translating "Out of stock" and other messages set in Rules
- Out of stock Text or Link instead of a disabled button
- Backorder / Waitlist Capabilities see comment #17 for a good approach.
Commerce Stock - Version 1
Check out Randy Fay's Stock V1 Screencast
No new features for version 1 so maintenance only.
To install and configure
- Install and enable the module.
- Visit admin/commerce/config/stock to enable stock tracking on your product type(s).
- Set the starting value of stock on each product.
The stock module does two main things
- Maintain stock levels
- Implement validation of stock to prevent users from ordering out of stock items
The module does the following stock validation checks
- Disable the add to cart button for out of stock products.
- Validates the add to cart quantity widget.
- Checks current Cart quantity when adding to your cart (so if stock is 10 and you got 6 in your cart you can only add 4)
- Checks that all products and quantities in the shopping cart (/cart) are in stock
- On Checkout if you attempt to enter, continue or complete with out of stock items you get redirected to the shopping cart.
If you are using multiple products per display and are not using attributes:
- Marks items as out of stock in the dropdown (version 1 only)
Management of stock
Each product type that is to be stock controlled is to be enabled using the admin interface.
Enabled product types will have a stock field added to them; this field will hold the current stock count.
A rule is created by the module to decrease the stock level when an order is complete.
The modules also provides some rule conditions and actions (increase / decrease stock) for you to create your own custom rules
- Ability to disable stock checking for specific products
Upgrade path from version 1:
I haven’t looked into this so any help will be great. For now just be aware that all rules have been rewritten.
If you have existing products with stock you will need to disable stock on all product types first, so the new decimal field gets created, you can probably backup and restore your stock using some SQL.
See also Issue 1800666
to keep up with development plans see the Roadmap
- Maintenance status: Actively maintained
- Development status: Under active development
- Module categories: Commerce/Advertising, E-commerce
- Reported installs: 12,215 sites currently report using this module. View usage statistics.
- Downloads: 97,302
- Last modified: 16 May 2016
- Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.