Product attributes are an important tool in WooCommerce which lets you group products into groups by shared characteristics. Attributes are what allow us to define the different variations. These are minor differences in the product such as color or size. Attributes can be added for any product type for filtering and they are essential for creating variable products. You can read more in the official WooCommerce Docs article.
In the Add Product article, we covered the basics of building a form for adding simple products. If you haven’t read that yet you should stop and read it through before continuing. In this guide, you will learn how to allow your users to add attributes to products.
Attributes Field
Attributes have a name and contain values/terms. For example, you might have an attribute called Size whose values/terms are Small, Medium, and Large.
There are four sub-fields in an attribute field: Name, Locations, Custom Terms, and Global terms.
On the front end, the field shows the available options when the user adds a new attribute to a product (number 1 below). Additionally, if you have any global attributes they can be used as well, and the options for them are shown as well (number 2 below). New Global Attributes must be added through the WooCommerce Dashboard.
Note that the “Used for variations” option is only visible if Variable Product is selected in the Product Type field.
You can also duplicate or delete attributes by clicking the buttons at the top right of the field on the front end.
Adding Custome Product Attributes
The user must add a name and values, by clicking the Add Value button. Multiple values can be added by typing the first one and hitting enter, then typing the next value. This attribute will not be reusable in other products, you will need to add the data again manually.
Global Attributes
If you want attributes to be easily reused across many products, then you must first add them through the WooCommerce plugin before applying them through Frontend Admin. Once you have added global attributes through WooCommerce, the name will already be defined and there will already be options to choose fro, when adding values. Only then, the user can choose from the existing terms by clicking the dropdown. They can also add new terms by clicking the Add New [attribute name] button. Multiple values can be added by typing the first, hitting enter, and then typing another value. These values will be added to the global attribute and can be reused later.
Saving
A front end user must check Use for variations and save changes after adding Attributes before they can add Variations.