Exporting and Importing WooCommerce Orders

I was recently tasked with migrating a legacy WooCommerce store into a newer environment and database. Here’s a couple of approaches you can consider if faced with a similar project.

The common approach – full database table migration

The most common way to do this migration is to copy your staging site progress to another development environment, use WP Migrate DB Pro* to pull selected database tables into the staging environment, then export/import any new site pages, posts, post types or new products that were in staging back in. Typically you will want to bring ALL wp_woocommerce* tables over plus all wp_comment*wp_post*wp_term*wp_user* tables, likely excluding wp_options since that contains settings for the new site’s plugins and environment. You can skip wp_woocommerce_sessions since that’s just active carts.

That must be done while the legacy site is in readonly / maintenance mode so new orders don’t trickle in during this potentially lengthly merge process. Migrating the posts tables will bring over all blog posts, products and custom post types, so you will be re-importing any contents that were in staging. All table IDs related to users and order/product histories will remain intact.

The alternative to full database table migration

What if you are importing orders from a non WooCommerce site, or you don’t mind order and user records having different database index IDs and just want to import the data?

First, ensure all of your products have SKU values set and migrate them over using this core technique from my earlier blog post. If you are migrating products from a non WooCommerce source, you will need this extension* to import those from a file.

Next, there’s a couple of commercial extensions that offer WooCommerce customers and orders exporting and importing: Xadapter and SkyVerge. I’ll cover the latter solution since it is the official extension set. Links to the two extensions are as follows:

The main thing to understand is that WooCommerce order numbers by default are the order ID, which is the autoindex post ID in the wp_posts table. It’s highly unlikely you will be able to maintain the exact ID between sites, unless you are doing the entire DB table swap mentioned above. So to account for order ID differences you need a system of order number merging.

To merge orders by number (not ID) you can use an extension such as Sequential Order Numbers on both the source and destination sites to maintain order numbers and match them accordingly during import.

The same applies to customer records. Match those by username or email address instead of the wp_users table ID.

The same applies to product records you have already imported. Match those by product SKU values instead of the ID. If you fail to map products correctly, prior orders will still contain their original products, but will not link properly.