Variable products are a great feature of WooCommerce for offering variations of a product with different prices, stock and more.
They can be used for offering variations of a product e.g. a large t-shirt vs a small t-shirt. Each variation can have different properties and prices.
Adding attributes for variations
Set the product type
To add a variable product first selection the type ‘variable’ from the product type dropdown. The interface will change to reflect your selection.
Choose the variation type
Define variation attributes
On the attributes tab add some attributes to your product – you can use global attributes (see Setting up product attributes) or define some custom ones specific for your product.
Add your attribute to the product
Make sure to assign all values of the attribute to the variable product which will become options and check the ‘variation’ checkbox on each attribute to tell WooCommerce its for your variations:
Add attributes and ensure the variations checkbox is checked
After saving your product you can now begin to add variations, or link all possible variations. To add a variation, click the ‘add variation’ button. A new blank row will appear ready for you to input the data.
A new variation
Each variation of a product may be assigned the following data:
- An image – click the icon to see the image uploader. After you choose an image click ‘insert into post’.
- SKU – Set the SKU for the variation, or leave blank to use the parent products SKU.
- Stock quantity – Stock for the particular variation, or left blank to use the parents stock settings.
- Weight – The weight for the variation, or left blank to use the parents weight.
- Dimensions – The dimensions for the variation, or left blank to use the parents dimensions.
- Price – The variations price. Required.
- Sale price – The variations sale price.
- Downloadable – If this variation is a downloadable product, check the box. You can then input file URL and download limits.
- Virtual – If the variation is virtual, check the box.
- Enabled – Uncheck the box to disable the variation. It will no longer be available.
- Shipping class – Shipping class can affect shipping. Set this if it differs from the parent.
- Tax class – A tax class for this variation. Useful if you are offering variations spanning different tax bands.
If the sku, weight, dimension, and stock fields are not set then it simply inherits the values assigned to the parent variable product. Price fields must be set per product.
Above the variations you have access to some bulk editing tools to speed up data input:
Bulk edit variations
Linking possible variations
Instead of adding each variation one at a time, you can click the ‘link all variations’ button. This will create a new variation for each and every possible combination of variation attributes (max 50 per run).
So if your example you had 2 attributes – colour (with values blue and green) and size (with values large and small) it will create the following variations:
- Large Blue
- Large Green
- Small Blue
- Small Green
Setting default variations
On the frontend, variations need to be selected before an add to cart button is displayed. However, if you define a default variation to use then it will be displayed immediately:
The result: Frontend
On the frontend, when viewing a variable product, the user will be presented with dropdown boxes to select the variation options; selecting options will reveal the stock, price and add to cart button for the variation so the user can purchase the product. The user will only be able to select variations that exist (and that are enabled) – non-existing variations will be greyed out.
Variations on the front-end