So, you need to Migrate WooCommerce: Like birds migrating away for the winter, sometimes businesses need to migrate data to new homes, except maybe less seasonally. A great example of this is when you have a shop and need to migrate WooCommerce. This could be merging two stores with one another, to tidy up your databases or to move into a completely new hosting environment.
Since you are reading this, you are probably aware that a simple process to Migrate WooCommerce unfortunately does not exist. You already may have heard the story “That’s not possible” or “Don’t bother, it’s too expensive”. Let us be the cat among the pigeons here, and clearly say that it is in fact possible, and inexpensive to do. To migrate WooCommerce is simply part of our day-to-day job. We have done it for others, and can do it for you, too. However, if you want to read more about the process to migrate WooCommerce then continue reading.
What about the other way round? How can I sync changes from a staging site to a live site without overwriting orders and subscriptions? How can subscriptions be transfered?
Migrate WooCommerce: The Challenge
Firstly, let’s look into the process – don’t worry, we won’t go too much into the weeds with this. WooCommerce is an extension of the WordPress CMS, that makes it possible to easily sell your products through a shop within your website. As every CMS, WordPress does the work of calling the information required from the database and rendering in the front end.
If you copy your data from shop A to shop B (in effect copying the whole database) then you will end up with both shops containing data. This is a typical use case for the scenarios mentioned above. With this simple copy and paste you end up overwriting the data of one of the shops, i.e. if you copy from shop A to shop B, you replace all the data on shop B, with data from shop A. Think of ‘copy-paste’ in simple terms. This circumstance is called “two sources of truth”.
Migrate a WooCommerce Shop: WordPress Tables
Every database consists of tables. The number of tables depends on the size of your WordPress instance and the types of extensions (or plugins) you use.
Even tough WooCommerce does the hard work of creating the tables and reference points to your own tables within your database, product information and order information are saved in the main WordPress table, called wp_posts. That means, when you copy this specific table to copy your products and orders, your posts, pages and every other information is copied across as well and again you overwrite the data of your second shop.
Within one database, tables cross-refer to each other. That means that not all your product information is saved only in the wp_posts table. For example, you also need wp_postmeta with the right reference to the wp_posts entry to correctly serve all the information you’re looking for.
Migrating WooCommerce products is simple in comparison to orders, don’t get me started on what you need to consider for subscriptions!
Migrating WooCommerce Orders
But that’s not all, when you migrate WooCommerce tables and data you need to consider things like your order numbers (which naturally you would want to keep). These cannot be just copied and migrated with two sources of truth, we need to go a step further and create a single point of truth.
Order numbers for example are pulled from the ID that the order gets within the table of the database. Every ID needs to be unique and can only exist once in each table. The ID is the unique identifier of the table row and is sometimes referred to UID, i.e. Unique Identifier. If you don’t have a unique identifier then you may ultimately create conflicts with duplicate IDs or overwrite elements of the existing data which would cause fatal problems on your page.
Another example of the challenge you might face is that the result of a direct migration may be that your orders no longer match to the correct customers. This is again related to the cross-references in your database which is not necessarily true with a copy and paste migration.
As you can see, it’s not only one challenge you have. It’s a complex scenario with a required attention to detail.
Let's talk about migrating two shops...
The Solution For Migrating WooCommerce
To be able to migrate two sources of truth into one you firstly need to agree which system will be your leading system in the future. Let’s say for the sake of this example we choose shop A as your future shop.
Before any data can be migrated we need to make sure that all information you’d like to migrate from shop B to shop A has a place to go to. That means, all related plugins you use in shop B must be installed in shop A. This ensures you have a direct mimic of shop B in shop A and that shop A will be able to display the data required.
If you use a plugin to customise your products in shop B for example and you want to use another plugin in shop A to do the same, that’s also possible, however this may require more work behind the scenes. It’s important to note though that this shouldn’t be a blocker to the migration, just do a quick sanity check first and ask yourself if the plugin switch is really essential.
It’s important to know if your products in shop B, that you want to migrate to shop A already exist in shop A or if they are completely new. Are there customers registered in both shops and is it possible that one customer is a customer of both shops?
From here onwards the migration is database related work. That means you would need to make changes on the core elements of your website installation that are relevant to ensure your website works as expected, as not all database related issues are visible immediately. You may create errors in your user journey without recognising, so my top tip is to err on the side of caution and be careful when you work in your database. You should always make a backup of every system before you make any changes.
Use Cases: Why should I consider to migrate WooCommerce shops?
A migration scenario as described above might be something you want to do ones because you have a need to migrate from two shops into one, because you want to migrate a staging to live or live to staging environment or because you want to have a fresh shop system to start with after undergoing a new website design.
Another use case might be on a more regular basis. When you regularly migrate data from one to another system to ensure all systems you use are up to date. The process for this type of migration varies from the one time process, but the rules to follow are the same as described above.
If you are looking for the “other way round” migration, where you sync changes from a staging site to a live, then we have prepared an article on how to migrate everything but orders, users and products. This might be relevant especially when you are using staging sites more regularly – which we highly recommend by the way- or if you capture subscriptions in your shop and you want to make sure you keep the payment records in order to ensure that recurring revenue continues to come in without any customer interaction.
It’s All About Team KAYBE
If you don’t know where to start, we are here to help. We have successfully migrated WooCommerce shops with large amounts of orders, customers and products and are confident to be able to help you through the jungle of database tables and information migration. Websites, webshops and the data that sits behind is what we love.