In this tutorial you will learn how to add custom fields and taxonomies to your WooCommerce products.

Adding custom fields and taxonomies to WooCommerce products - outcome of this tutorial
Adding custom fields and taxonomies to WooCommerce products – outcome of this tutorial

This tutorial is the first part of the “Customizing your WooCommerce site without PHP” series.

Learn by doing

Learn by doing - WooCommerce training site
Learn by doing – use WooCommerce & Toolset training site

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.

Create your free training site


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
  • taxonomies

If you already know the difference between these two, feel free to skip to the next section.

The definition of a custom field is “arbitrary extra information”. The WordPress definition of a custom taxonomy is “a way to group things together”.

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?

A custom field or a custom taxonomy?
A custom field or a custom 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.

Adding a group of custom fields to WooCommerce products
Adding a group of custom fields to WooCommerce products

In your training site:

  1. Go to Toolset->Dashboard.
  2. Locate the row for Products.
  3. Click Create Field Group.

Adding product custom fields
Adding product custom fields

The Edit Post Field Group screen opens. Here you create a group of fields for your products.

  1. Give your group a name: for example, Product details.
  2. Click Add New Field.

Choosing a type for your new field
Choosing a type for your 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.

  1. Click Single line.

Setting up a new product field
Setting up a new product field

  1. Give the field a name: for example, Special offer
  2. Click Save Field Group.

Your group with a custom field is ready. Let’s populate it with some data.

Populating custom fields with data

Populating custom fields with data
Populating custom fields with data

In your WordPress admin area,

  1. Go to Products.
  2. 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.
  3. Type in your Special offer message.
  4. Save your product post.

Adding a Custom Taxonomy to WooCommerce Products

Creating a new custom taxonomy for products
Creating a new custom taxonomy for products

To add a custom taxonomy:

  1. Go to Toolset->Dashboard.
  2. In the Product row, choose Create Taxonomy.

Adding new custom taxonomy to products
Adding new custom taxonomy to products

  1. Give your taxonomy its singular and plural names. We will use “Gender” for both (there’s no plural for “gender”).
  2. 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.

Adding taxonomy terms for a product taxonomy
Adding taxonomy terms for a product taxonomy

Go to Products->Gender and add the following new genders:

  • Men
  • Women
  • Children

Taxonomy terms in a WooCommerce product editor
Taxonomy terms in a WooCommerce product editor

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.

How to use the “Bulk Edit” feature to assign many products at once to a specific taxonomy term.
How to use the “Bulk Edit” feature to assign many products at once to a specific taxonomy term.

  1. Go to Products and check the products you are going to bulk-edit.
  2. Select Edit from the drop-down list and press the Apply button.
  3. On the next screen, pick the relevant gender term and save the changes.

Summary

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.