Sean Conklin, WooCommerce Developer, Sean@CodedCommerce.com, (818) 835-5960

Exporting and importing orders

08/27/2018
Exporting and importing 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:

  • Customer Order CSV Export* for exporting from an existing Woo site
  • Customer Order Coupon CSV Import Suite* for importing into the new site

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.

Share this

  • Mail
  • Facebook
  • LinkedIn
  • Reddit
  • Twitter

Need help?

  • Contact us

Blog Categories

  • Events (11)
  • Marketing tips (25)
  • Official blog reposts (10)
  • Popular (10)
  • Technical tips (55)
  • Videos (12)

Code Categories

  • Back-end code snippets 6060 products
  • Cart 2020 products
  • Checkout 2121 products
  • Elementor code snippets 88 products
  • Front-end code snippets 147147 products
  • JetPack code snippets 44 products
  • Navigation menus 22 products
  • Official extension related 2626 products
  • Payments 66 products
  • Product pages 2424 products
  • Search 77 products
  • Shop and product categories 1616 products
  • Sitewide 3838 products
  • Storefront code snippets 1717 products
  • Useful functions and libraries 55 products
  • User accounts 2424 products
  • WooCommerce Code Snippets 229229 products

  • Home
  • Blog
  • Code
  • Contact
  • My account
  • Privacy policy

Copyright © 2018-2022 Coded Commerce, LLC.
Automattic Inc. owns and oversees the trademarks for Woo™ and WooCommerce®.