Exporting & Importing WooCommerce Orders
All us developers find ourselves in a situation where we are required to move over customer orders from one WooCommerce website to another. This always seems pretty straight forward to begin with. Then we realise we cant export and import the entire website because in between our development project the live website has had lots of updates to its database e.g. other new orders, new customers and much more.
Recently this is the situation we found ourselves in and we used two plugins to begin with:
These basic plugins created by SkyVerge did most of the job for us, exported all our orders and imported them but guess what? Yes, all the custom meta, custom invoice data or what ever that was unique to the order was not moved over so it only half did the job.
So what did we do? We created our own custom scripts to finish the job.
First we ran a script on the development server pulling all the meta data from wp_postmeta and created a custom JSON package with a unique key (something that we could find again on the live website e.g. billing name and order total).
Once we got our JSON package with all the meta data we need, we created a separate script on the live website looping through all the orders we had just imported, using the unique key we made we found which order it was for and imported all the meta data into the wp_postmeta linking it up to the orders.
BANG! It was all moved over successfully. If your wondering why we didn’t use the order ID as the unique identifier, thats because the plugins we used above imported the orders with totally new IDs.
So there you have it, another day, another job.
If you have any questions or a project that is having simular difficulties get in touch with our super talented team who always come up with bespoke solutions to your problems.