How to add custom fields to your WooCommerce customers
Do you want to be able to add some extra information about your WooCommerce customers? Maybe a phone number of the customer, or a short specific information that your online store needs. In the following article I’m going to show you how to add custom fields to your WooCommerce customer profiles and how to use the WooCommerce customer custom fields data to search and filter your customers.
Benefits of using WooCommerce customer custom fields
Custom fields allow you to store additional information about your WooCommerce customers. There are many use case scenarios and benefits of creating custom fields for your customers, some of which are:
- Store additional information about your customers.
- Ability to personalize your customer profile.
- Create custom segments based on your custom fields.
- Improve your customer management and organization.
- Share important customer information internally with your team.
In this tutorial we are going to use the custom user fields and the custom user profiles features of Users Insights. These features come with the Users Insights plugin by default. We are also going to use the WooCommerce module of Users Insights that is bundled into the plugin as well. Before we start, you have to make sure that you have the WooCommerce module activated on your website. You can activate and deactivate the available modules from the Module Options page of the plugin.
Please note that since Users Insights is a user management plugin, this feature can only work for the WooCommerce customers that are registered WordPress users.
Creating the custom fields
The custom fields feature of Users Insights can be accessed from the Users Insights -> Custom Fields menu in your WordPress dashboard. When you open the Custom Fields page, you will see a form that allows you to create your own custom user fields. All the existing custom user fields, if any, will be listed in a table below this form.
The form for creating custom fields consists of three fields. The first one is the name of the custom field. The name will used to identify the field in the Users Insights user table, custom user profile section, as well as in the Users Insights filters. The second field is the user meta key. This is the name under which the custom customer field will be saved in the database. The key should be in the following format: “example_user_key”. You can also use existing meta keys if you already have some customer data stored as user meta. The existing user meta will be automatically detected in the Users Insights table and custom profile page. The third field is a drop down select option that gives you the option to choose the type of the field. Currently, the custom fields feature supports text and numeric field types.
Let’s say, for example, that you want to create a custom field that you want to use to store an alternative email address of your customers. This might be a different email from the one set as a main account email address. In order to add a new custom field, all you need to do is to create a new field called “Secondary Email”, select a key name and choose the field type. For this example, the type of the field will be “text”.
Adding and editing the custom field data of a customer
If we now open a Users Insights customer profile, we will see the newly created field listed in the customer details section. You can access the profile section by clicking on any customer’s username in the Users Insights table. You can update the data of this custom field by clicking on the edit button next to the field name. To save the changes just click on the “done” button.
Showing the custom fields data in the user table
All the custom fields that you have created for your WooCommerce customers are also automatically available in the Users Insights table. If the newly added custom fields are not visible in your customer table, you will need to make them visible first. You can show and hide the table fields by clicking on the “eye” icon in the top right menu of the Users Insights page.
Filtering your WooCommerce customers by the custom fields data
The custom fields are also available in the Users Insights smart filters. This means that you can search and filter your customers by their custom fields data. For example, if you want to see all the customers who have a second email address set, you can use the filter “Secondary email is set”:
If you want to search for a specific email address, you can use the filter “Secondary email contains” and type the email address you are looking for:
You can also use the same filter to search for a range of emails. For example, to find all the customers who have a secondary email address set as a “usersinsights” email account, you can add the filter “Secondary email contains usersinsights”:
Combining the custom fields with other filters
Since the Users Insights filters are stackable, you can use multiple filters at once. This means you can combine the custom fields filters with the rest of the filters that Users Insights provide. An example of this would be to find all the customers who have a secondary email set from a specific domain and are from the United States:
As you can see, using custom fields to store extra information about your customers can be quite useful in many different situations. We hope that this article helped you learn how to create WooCommerce customer custom fields, as well as how to use the data from these fields to better organize and manage your WooCommerce customers.