This tutorial is the first part of the “Customizing your WooCommerce site without PHP” series.
Learn by doing
This tutorial uses the Toolset Types plugin, which is a free Toolset component.
Use the free training site, which allows you to follow the entire tutorial, step by step, from inside the WordPress admin area.
Your training site will include sample products and all needed plugins installed.
The Difference between Custom Fields and Custom Taxonomies
Before we add these extra pieces of information to our products, we need to decide which WordPress structure will work best for each. Basically, WordPress offers two ways for storing additional information for your posts:
- custom fields
If you already know the difference between these two, feel free to skip to the next section.
Let’s take a closer look at the specific information we want to enhance our products with. This will enable us to decide when to use a custom field and where a taxonomy fits better.
“Special offer” – a custom field or a taxonomy?
“Special offer” will include promotional text about certain products to make them more attractive for potential buyers.
Only some of our products will have a special offer available, and the offer for each product will have its own wording.
The “Special offer” is definitely a piece of “arbitrary extra information”. That’s why we implement “Special offer” using a custom field.
“Gender” – a custom field or a taxonomy?
Most shops have different departments for women, men, and children. So we understand that gender is a way to group products. This means that we should implement “gender” as a custom taxonomy.
Custom taxonomy versus product categories
We could also use Product Categories to classify products by gender. However, in our case we are already using Product Categories to group shoes by a different criterion, namely: “shoe types” (we have heels, boots, sandals, slippers, etc.).
When you need to organize products by a different criterion, you should create a new custom taxonomy.
Adding Custom Fields to WooCommerce Products
Let’s see how you add a new custom field to your WooCommerce products.
In your training site:
- Go to Toolset->Dashboard.
- Locate the row for Products.
- Click Create Field Group.
The Edit Post Field Group screen opens. Here you create a group of fields for your products.
- Give your group a name: for example, Product details.
- Click Add New Field.
A pop-up with different field types opens.
In our case, we need a text field to store a short promotional message, so we choose the Single line field.
- Click Single line.
- Give the field a name: for example, Special offer
- Click Save Field Group.
Your group with a custom field is ready. Let’s populate it with some data.
Populating custom fields with data
In your WordPress admin area,
- Go to Products.
- Edit any of the products on your site. Under the main editor, you should see the new group you created containing the “Special offer” custom field.
- Type in your Special offer message.
- Save your product post.
Adding a Custom Taxonomy to WooCommerce Products
To add a custom taxonomy:
- Go to Toolset->Dashboard.
- In the Product row, choose Create Taxonomy.
- Give your taxonomy its singular and plural names. We will use “Gender” for both (there’s no plural for “gender”).
- Click Save taxonomy.
Your taxonomy is ready.
If you open any product for editing, you should now see the new “Gender” taxonomy on the sidebar.
Adding taxonomy terms
Before we start using the Gender taxonomy, we need to create the actual genders: Men, Women, and Children. These are called taxonomy terms in WordPress terminology.
Go to Products->Gender and add the following new genders:
Once these genders have been added, you will see them in your product editor.
Setting gender for products
When all your gender terms have been set up, you can assign your products to them. If you want to set a single gender for a few products at once, use WordPress’s “Bulk Edit” feature.
- Go to Products and check the products you are going to bulk-edit.
- Select Edit from the drop-down list and press the Apply button.
- On the next screen, pick the relevant gender term and save the changes.
In this tutorial, you learned how to add a custom field and a custom taxonomy to your WooCommerce products so they appear in your WordPress admin.
In the next parts, you will see how to design WooCommerce product templates and then how to add custom fields and taxonomies to templates, so they appear on the site’s front-end.