This guide will demonstrate how to perform a woocommerce customer export. The procedure is useful for a variety of purposes, but the most popular is for usage in email marketing campaigns.

If you do plan on sending emails to your customers, please make sure you have their consent. Automated email marketing without user consent may be against the law in your country.

Available Approaches Cost Money

A quick Google search shows some plugins available for this task. The price tag for these varies, but we won’t consider these.

This guide is focused on achieving this task with zero costs. As a result we will need to write some of our own code to achieve this task.

How Customers are Stored by Woocommerce

By taking a look at our WordPress database, we can quickly see that customers are stored in the users and usermeta tables of our database.

The first table stores the basic information we may require. This includes:

  • user_login
  • user_nicename
  • user_email
  • display_name

This may be enough for some people, we the majority of us will also need some more details. The usermeta table has the following additional information:

  • first_name
  • last_name
  • billing_email
  • billing_phone
  • billing_country
  • billingaddress1
  • billingaddress2
  • billing_city
  • billing_state
  • billing_postcode

This information is tied to the user table using the user_id table field.

For the sake of simplicity, we will assume that our customers details correspond to the billing information provided and not the shipping information. It is difficult to determine what the most accurate approach, but this is the one we will take.

Extracting Woocommerce Customer Information to a CSV File

Now we need to pull all of the data stored in these tables and put it into a csv file which we can then download.

There are several way’s to accomplish this, but using a native WordPress user query seems to be the easiest.

Here is a piece of code that will get all the customers and their most important fields (discussed above) and print them into a text box.

This code snippet also pulls in the order count for each person. This information can be useful if you wish to segment your customers by loyalty.

Other ideas include:

  • How much money they have spent at your website
  • Average order size
  • Time since last order

But these additional data points would need some additional coding to be exported from our website. And this will not be discussed here.

Alternate Approach

The strategy above extracted only those customers who created an account the website. The alternate approach would be to pull all the customers from the database relying on order data.

Using the wp_query on all the posts will run into issues for stores with upwards of 200-300 orders. As a result it doesn’t make sense to use that approach.

Instead here is some code which will grab order data directly from the database:

(All columns are formatted exactly how Mautic wants them).

The code above should be modified corresponding to your database settings and what orders you wish to extract.

Where to Put This Customer Export Code

If you are comfortable with WorPress theming and templates, you can stick this code into any custom page (make sure to make it private). If your a beginner continue reading.

Individuals not familiar with WordPress theming can download the code above in a tiny little plugin here:

Simple WooCommerce Customer Export Shortcode

This plugin simply creates a shortcode ([woo-customer-csv-export_text]) that can be used on any page or post of your website. The recommended use case is to create a private page that only you can access and insert the shortcode there.

Now each time you need latest customer data, you simply open the page and the data is there.

Getting the Data into CSV File

The data that is output in the textarea is raw csv data. It still needs to put into a CSV file that can be opened by spreadsheet software or import into marketing software.

To put this data into a csv file:

  1. Open your favorite text editor and create a new file
  2. Copy the text from the textarea and paste into the file
  3. Save the file and use .csv as the ending/extension

Now you have a fully functional csv file.


If you followed along, you should now have all your woocommerce store customers in a neat CSV file ready for use elsewhere.

This approach isn’t the most optimized or extensive, however, it is absolutely free and the data is all there. You can make modifications to the code as you see fit and ideas are welcomed in the comments section below.

Additionally, If you have any questions or issues with this approach to woocommerce customer export, then drop a comment below.

Share Your Thoughts

(will not be published)

No Comments

Be the first to start a conversation