Add a custom attribute for a product
In this tutorial we will add a product specific custom attribute. These are not attributes that will be filterable via the WooCommerce Layered Nav. These attributes are stored specifically for a product.
In this article
Here's an example of a custom attribute for a product.
Add custom product attribute
Here's how to add the
promo field as a custom attribute for a product.
Identify the product field
First we need to see if our products have a
promofield. Here's a product that does have a
Create a custom plugin
If you haven't done so already, create a custom plugin.
Add custom code
Add the following code to your custom plugin file.
Add/Update product sets
Now, after your Product Set imports its products, a " promo" attribute will be added for each product that has a
promofield. The label will display "Special Promotion".
Prevent attributes from being overwritten during update
To prevent your custom attributes from being overwritten during a Product Set update, you'll need to use the code below instead of the code above.