# Basic Usage
# Add stock to an attribute
Adding stock to an attribute is almost exactly the same as adding stock to a product. Simply navigate to the product attribute you want to add stock to, e.g. Products
> Attributes
> T-Shirt Sizes
> Medium
, and set the stock fields accordingly:
- Manage Stock? — Toggle stock management for this attribute term.
- Stock quantity — Set the current quantity for this attribute term.
Once stock has been enabled and set for the attribute, you can view it conveniently from the list of attribute terms.
# Attribute-level stock
Stock can also be enabled and set at the product attribute level. That is, the stock quantity is not set per attribute term, but instead is set for the entire attribute. This is similar to product-level stock vs variation-level stock.
This type of stock is useful for when you need different amounts of stock to be deducted per attribute term. For example, if you sold Tea per grams, you could set your total Tea stock on an attribute Tea
and add attribute terms such as 25g
, 50g
, 100g
, etc. Each term can then be set to deduct the respective amount from the total Tea
stock using the quantity multiplier option.
# Link products to attribute stock
All you need to do to start tracking attribute stock for your products is to add the attributes to your products just like you normally would. Attribute stock can be added at the product level, or per variation by checking the Used for variations
option.
All attributes with stock enabled will immediately start reducing stock when products are purchased. Cancelled and refunded orders will restore stock automatically, just as you'd expect with normal product stock.
Remember, attribute stock and product stock are separate types of stock. You can even use both types of stock on a product at the same time. However, it's common to manage your stock exclusively with attribute stock. In this case all you need to do is disable Manage stock
and set Stock status
to In stock on your products and variations.
Be sure to read How product stock limiting works for more info on this subject.
# Variations with "Any" attributes
Attribute stock fully supports variations that have "Any" selected for one or all of its attributes. This means you don't need to add multiple unnecessary variations to your products in order for attribute stock to function correctly.
There are however some edge cases with this. For example, some "Back in stock notifier" plugins save a specific variation ID to a customer's waitlist, but don't save the current selection of attributes. This means attribute stock has no way of matching the correct stock items. So it's important to make sure you test your products thoroughly when using variations this way.
# Product types
By default, all product types that can manage stock (e.g. simple and variable products) can make use of attribute stock.
Product types that cannot manage stock, such as grouped or external products, will not affect attribute stock even if the attribute has been assigned to the product.
Simple products will match attribute stock according to all assigned attributes, whereas variable products will match according to each variation's attributes individually. The exception to this is attributes that are not used for variations — these attributes will be used by all variations for matching.
TIP
Valid product types can be filtered per attribute stock from the advanced interface.
# Exclude products
If you don't want a particular product to make use of attribute stock, you can simply exclude it by enabling the Ignore attribute stock
option:
Or per product variation:
TIP
Setting Ignore attribute stock
at the product level will exclude all variations, regardless of their individual setting.
# Site-wide settings
Attribute stock includes a few global settings for further control of your stock. You can find these settings under WooCommerce > Settings > Products > Inventory > Attribute stock.
- Limit product stock — Auto / Everywhere / Disabled
- When set to 'Auto', product stock will only be limited on the frontend, in cron tasks, and during certain actions. Setting 'Everywhere' will limit product stock in admin views, and may improve compatibility with other plugins.
- Allow backorders — Do not allow / Allow, but notify customer / Allow
- Allow backorders for products using attribute stock, when product stock management is disabled. Does not affect products with stock management enabled, or products that are not using attribute stock.
- Out of stock variations — Out of stock / Greyed out / Hidden
- Select how variation options will be displayed when out of stock. This only applies when "Hide out of stock items from the catalog" is disabled, and affects all variation options site-wide regardless of attribute stock.
- Unmatched "Any" variations — No change / Out of stock / Greyed out / Hidden
- Select how "Any" variation options that don't match attribute stock will be displayed on the frontend. Only affects variations with "Any" selected for some or all attribute terms.
- Trigger product stock actions — Enabled / Disabled
- Trigger product stock change actions when attribute stock changes. Many plugins require these actions to know when stock changes on your site. However, in some cases this might cause issues with certain plugins, or simply not be needed and use unnecessary server resources.
# WooCommerce settings
In addition to the above settings, attribute stock will also respect all of the default WooCommerce inventory settings, such as Manage stock, Stock notifications, Stock thresholds, Out of stock visibility, and Stock display format.
# Shortcode
In some cases you may want to display attribute stock levels on arbitrary pages or areas of your site. To do this more easily we've included a simple shortcode that you can use. Usage is one of the following:
- [attribute_stock id=123]
- [attribute_stock sku="ABC123"]
- [attribute_stock title="My Stock Item"]