How to import WooCommerce customers from a CSV file

In this article we are going to show you how you can do a WooCommerce customer import from a CSV file. Sometimes you might need to move your customer base from one platform to another. So today we are going to look into how you can use some tools to import your customers data from a CSV file. In this way you’ll be able to import your customer data directly into WooCommerce. The customers will be created as WordPress users with some custom fields such as name, address and company.

One of the most terrifying tasks in web development is migration. Even though sometimes we need to move servers or platforms, a lot of data can be lost. That’s why using export files can save you a lot of trouble.

Export files are ways to communicate between completely different systems. They translate your data into a standardized “language” so everyone will be able to make sense of it. Even when moving from similar systems, it’s also helpful to use them to make sure no data is lost. That’s the role of the CSV format and other similar formats.

Therefore, our goal in this article is exploring plugins that you can use to help you import WooCommerce customer data from CSV files. Our main topics are:

  • Installing WP Ultimate CSV Importer
  • Planning your Export
  • Running your Import
  • Linking past orders to the users

So, let’s get started!

woocommerce customer import

Installing WP Ultimate CSV Importer

We’ve done a similar process in the past. In our “How to Import Your WordPress Users from a CSV File” article, we saw a couple of plugins that can do this job. Our tool of choice today is again the WP Ultimate CSV Importer.

This plugin allows you to import not only users but many custom post types and custom fields. In this way, you can not only import users, but also import orders, posts, products or anything else you’ve got.

To install the plugin, just go to Plugins > Add New and search for “WP Ultimate CSV Importer”. Once installed, we just need to activate it and we’re good to go.

Activate plugin

 

Planning your Export

Before starting the upload and import we need to make sure you have all the essential information that we need. The process of exporting the user data can vary depending on your current platform. We already have an article about how to export your WooCommerce customers with their address with Users Insights, however we’ll also provide some general instructions on how to setup your CSV file in case you prefer using a different tool.

For WooCommerce we’re focusing on fields such as address, company and name. Make sure you have these in the same format that WooCommerce does. For example, in your address the City has its own field, and your data export should be that way as well.

Don’t be afraid to use pen and paper for this process. You need to analyze how your current database stores your user data, so you can correspond them to the new way of storing data. If you get this correspondence right, your import process will work smoothly.

These are the fields we have in our WooCommerce export:

  • Address ( billing_address_1 , billing_address_2 , shipping_address_1 , shipping_address_2 )
  • Company ( billing_company , shipping_company )
  • City ( billing_city , shipping_city )
  • State ( billing_state , shipping_state )
  • Country ( billing_country , shipping_country )
  • Postcode ( billing_postcode , shipping_postcode )
  • Phone ( billing_phone , shipping_phone )

But in case you don’t have any of these just leave them blank. Also, if you don’t have them for a user in specific you can leave them blank. WooCommerce will require them to fill that in next time they place an order.

 

Running your Import

Once you have all your data ready in a nice CSV file we’ll run the import plugin. Now make sure you have a safe backup of your entire database (in case anything goes wrong).

Go to your WordPress Dashboard > Ultimate CSV Importer Free > Import / Update. Since the free version only allows uploads from your desktop select your file from there.

Upload CSV file

The next step is selecting the Import type to be as users:

Selecting users as import mode

We are now going to select the fields and assign them to the corresponding custom field names. Once again, since we are going to import the WooCommerce settings, make sure to assign the correct fields to the correct keys. In this way your customer data (such as address, company, name) are going to be saved correctly.

Also it’s worth noticing that the first part of the import is going to show your default user fields (created by WordPress), and you can see your custom fields below.

Here is the default fields mapping:

CSV Custom Fields

And this is how the custom fields mapping is going to look like:

Custom fields mapping

You may notice that some custom fields are already recognized. That happens when the plugin dettects custom fields that already exist, or field groups that are active (if you already have WooCommerce, for example).

 

Linking past orders to the users

Since our focus is dealing with orders you can repeat the same process with your orders. Although the process is very similar, you need to make sure you have all the custom fields required for the Orders Custom Post Type.

If you want to allow your users to see past orders and manage them, you need to link these orders with your users. For this process to work, your orders need to have the same email as your registered user. In case your users have multiple email addresses you’ll need to make sure the correct email is referenced.

In order to do that you need to import your orders, then add this snippet in a child theme or plugin before running the user import.

Once you save this, this code will link any past orders to the newly created customers. In this way all customers created in your import will have past orders linked to them.

Checking your imported customer data

After this entire process, it is always worth double checking our data. This can be done using the Users Insights plugin, as we can check our custom fields and orders integrity. Here are some ideas of searches you can run to check for possible errors.

You can use the username or email field to search for specific users. For instance, if you know that you have important customers with an email from a certain domain you can check that. It’s possible to check specific usernames or emails as well if you want.

Filter imported WooCommerce customers based on email provider

Then you might want to check the custom fields integrity, such as location, for WooCommerce users you imported. The visual check is a quick way to see obvious issues. You can make your WooCommerce location fields visible by clicking the eye icon.

Check imported users fields with Users Insights columns

Additionally, you can filter users based on these fields. You just need to check for users with empty locations to find any possible issues. This is done with the “is not set” condition.

Check missing fields on users import using the is not set filter

This could mean that either these users don’t have a location set, or something was wrong in your data source.

Next, we can check imported users for the WooCommerce orders assignment. Maybe you had different email addresses, or maybe you had some small issues in your data sources. You can identify these small issues easily if you check users based on their orders count.

Check imported WooCommerce users order integrity

Surely, this could simply mean that these users haven’t made any orders. In this case, it is worth double checking in your original source or using other methods.

Conclusion

Today we saw how you can import customers, their addresses, company and other custom fields. We also learned how you can apply the same technique and import orders, products and other custom post types.

Hopefully, by the end of the day you should be able to plan your export and import process. You should be able to migrate users and orders and perform similar tasks seamlessly.

We hope you enjoyed it, and see you next time!