Migrating WooCommerce Data to an Existing WooCommerce Store

When migrating data from a site to another that already has data like users, products, subscriptions, and other post types, the first thing to do is backup all your data before you make any changes on both sites. When making any changes on the website there is always a risk of losing data. And losing all that data and building the store all over again from scratch would be a nightmare scenario and not practical.

Now let’s consider a scenario where you want to make some changes to the WooCommerce website. The site already has some data in it and you want to add some more to it. You have a test site where you have all the data that you want to import to your new site, or you want to merge two sites together into one. In these cases, while transferring data from one site to another, there can be a potential conflict between the data being transferred to the existing data.

Under the Hood

Let’s get a glimpse of what goes behind the scenes in WordPress. The first thing to understand is how any data is stored in the WordPress database. All the content in WordPress is considered as posts. All the blogs and pages are considered as posts. Similarly, all the content added using WooCommerce and its extensions like products, orders, coupons, subscriptions, memberships, etc. are also considered as different post types. And they are stored in the table wp_posts in the database. The metadata and custom metadata are stored in table wp_postmeta.

Now, not only all these different types of content are considered as different post types and are stored in the same table, but they are all also identified by the same identifier, the post ID.

WordPress creates an auto-incremented post ID for every post. So if you enter a product in between an order, then the next incremented ID is assigned to the product. That’s why you can see that the order IDs are not always necessarily consecutive numbers.

The different data in a WooCommerce store are associated with each other. So a user will be associated with an order, the order will be associated with a product. Also, the users will be associated with other data like memberships, etc. All these data are usually connected to each other using post IDs.

Before you Migrate

Again, I cannot stress this enough. Be sure to first create a backup of all your data in both sites before making any changes. Then, make a note of all the data you want to migrate and how you want to migrate them.

So in this case, the site we are migrating the data to already has some data in the form of WooCommerce products, users, and orders. These data are stored in the wp_posts table and they are assigned a post ID unique in that website. So, when you import data from another site, it might also have post types with the same post ID in its database.

Now when this happens, ie, when WordPress encounters posts with the same ID, these are the possibilities – while importing, if the posts with the same ID are encountered, then the posts may be skipped, or the posts may be merged with the existing or the posts are created as new posts with a different post ID.

The important thing while migrating is to preserve the relationship between the different types of posts. This is where things can go wrong. Conflict arises when there is a dependency between different data using post IDs. So, for example, an order that is being imported is associated with a product using the product ID (post ID). When imported, if there is another product with the same ID in the new site there will arise a conflict. This will cause the order to be linked to the wrong product.

This can break the relationship between the posts and can cause the wrong data being associated with each other. When that happens, it can lead to a lot of mess and you would need to do all the fixes manually. This will lead you to spend more time and effort than you saved.

How to Migrate?

To migrate these data from one site to another is to export from one into a CSV file and then import the CSV file to the other. There are multiple plugins that can help you do that.

Choose the Right Plugins

If the only post type that you want to migrate are the products, then you can do that with just the WooCommerce plugin. But there are plugins that give more flexibility and control over the data that are imported or exported in the website. To import or export other data other than products like orders and users or other data that are created using WooCommerce extensions, you will need specific plugins.

To import the WooCommerce products from one site to another

To export the products and its related data in one site and then import them to another, the right plugin is the Product Import Export Plugin for WooCommerce. This plugin facilitates the migration of products from one site to another with incredible and flexibility. With this plugin, products from one site can be exported from one site into a CSV file. The plugin gives many options for the products to be exported into the CSV file.

Now after all the required products and their metadata has been exported to a CSV file, they can be imported to the other site. Install and activate the Product Import Export Plugin on the site where the CSV is to be imported. Then upload the CSV file, map the required fields and then import. This will add all the products and their details in the CSV file into the WooCommerce store.

The beginner’s guide will help you easily set up the plugin in your WooCommerce store. The plugin documentation is sufficient to guide you through setting up and using the plugin.

To import the WooCommerce users from one site to another

The WordPress Users and WooCommerce Customer Import Export Plugin helps you to move the users from one site to another. Install the plugin on both sites to migrate the data from one to the other. Using the plugin, export the user data from the source website in a CSV file to the destination site where they are to be imported. On the destination site, import the CSV file and map the fields of the CSV to the corresponding fields in the WooCommerce store.

You can read all about Setting Up WordPress Users & WooCommerce Customers Import Export Plugin in the documentation.

To import the WooCommerce orders from one site to another

The orders of a site can be transferred from one site to another using the plugin Order/Coupon/Subscription Import Export Plugin for WooCommerce. The plugin needs to be on both websites. On one side export all the required orders from one site to another. Order/Coupon/Subscription Import Export Plugin for WooCommerce gives you options to export orders depending on the status of the orders, start or end date of the order, also specify the number of orders that you want to export to the CSV or in XML format, and more.

Next, on the importing side, install and activate Order/Coupon/Subscription Import Export Plugin for WooCommerce and import the CSV file into the site. This will create all the orders on the new site and connect with the corresponding products and users if they already exist on the new website.

The documentation on How to Import and Export WooCommerce Orders Using Order/Coupon/Subscription Export Import Plugin will help you understand how you can export and import orders without with ease.

During Migration

Using the above plugins, the order in which these data are imported is important. The reason for this is that the orders in a WooCommerce store are linked with the users and the products.

During the import of the orders, the plugin searches for the related products and users and links them together. For an order, its related user is identified using the users’ customer e-mail ID. The products of an order are identified using the product ID and the product SKU (Stock Keeping Unit).

Here is where the post IDs creates a conflict. During the import, when products with the same ID are encountered, they are either skipped or the existing products with the same ID are updated. This will make the wrong product be linked to the order.

One way to ensure that the right product is connected with the orders is to retain the original post ID. Or, when using the Product Import Export Plugin for WooCommerce you can connect the products with the orders with just the SKU of the product. Before importing the CSV to the new site, remove the post IDs from the CSV. This will create products with new post IDs in the new site and the orders will be connected to the product.

If the related user or the product is not found, the order list will display the related user and the product, but will not be actually linked with them.

Migration Process Step by Step

1 – Install and Activate the Plugins

Install and activate all the required plugins on the origin website and the destination website. On the origin site for exporting the data to the CSV file and on the destination site for importing the data from the site to the site.

2 – Export data to the CSV Files

From the origin site export all the data to CSV files to different CSV files. There is no particular rule in exporting to the CSV file. All you need to do configure the settings of the plugins according to the way you want to export the data. You can configure the settings of the plugins to import only a portion of data, a data of particular category, etc.

3 – Import the CSV Files in the Destination Site

Head to the destination site and import the CSV file to the site.

Now while importing, you have to be careful about the order in which the data are imported.

First, import either the CSV with the user data or the CSV with the product data. After the two data have been imported to the website, then import the orders. This is to ensure that when the orders are imported, all the data required for the order are already present on the destination site.

While importing the products, the Order/Coupon/Subscription Import Export Plugin for WooCommerce will identify the related order and products using the product’s post ID (Product ID) and the product SKU. In case, while importing, the products are assigned a different post ID into the new site, the order can still be linked to the products using the SKU. In this scenario, The fix is to remove the attribute product_ID from the line items column in the CSV before importing the products CSV. This will link the products and orders using the SKU of the product when the products are imported.

While importing users using the WordPress Users and WooCommerce Customers Import Export Plugin for WooCommerce, there will be no issue even if the post IDs of the users change. The orders and users are associated with each other using the customer email ID.

And finally, import the CSV with all the orders.

4 – Do a Test Run

Try to do a test run of the whole process to make sure that everything works perfectly. If all is fine in the test run, then do a live import.

Wrapping Up

Even the thought of migrating a WooCommerce website can be scary. If you are migrating a website that has already in business, then it becomes really difficult to migrate a website to another. You are always in a worry of something going wrong that can potentially ruin your website and all of the hard work going vain. An average store owner might require hiring a WordPress expert for site migration. But with the right set of plugins and following proper steps, migration of a website can be something that can be done without the help of an expert.

Article by

Safwana is a technical content writer for WebToffee. She loves working in WordPress and writing about it.

Got any query? Please leave a comment or reach out to our support

Your email address will not be published. Required fields are marked *