Print

Skip WooCommerce Orders and Products

Skip WooCommerce Orders and Products

Whenever you use WP Staging Pro to push changes from the staging site to the live site you need to make sure that WooCommerce Orders, WordPress users, and WooCommerce products on the live site are not affected in any way.

You also need to make sure that if you make changes to the staging site and then push the changes, any orders, transactions, and users that were added in the interim will remain untouched.

So what is the best way to prevent those data from being overwritten during the pushing process?

First of all, we need to understand where WooCommerce and WordPress are storing transactional orders,  products data, user data like customer address and all other data like posts and pages:

  • Orders and products are stored in table wp_posts and wp_postmeta separated by the custom post type ‘orders’
  • WordPress itself also stores all its data like pages and posts in the same tables.
  • Users are stored in wp_users and wp_usermeta

There are also a bunch of other WooCommerce custom tables which store things like tax rates, order items, and general WooCommerce settings.

Each table name will be prefixed with a certain table prefix e.g. wpstg1_

The WooCommerce table names will be prefixed with the same table prefix but they also begin with _woocommerce like wpstg1_woocommerce_

The number in the prefix is the number of your staging site. So if you have multiple staging sites that number will be counted up like wpstg1_, wpstg2_ and so on.

If you want to migrate certain data from your staging site to the production site without affecting any of the transactional data you have two options:

A) Exclude relevant tables before you using the WP Staging push process. If you go that route you can not migrate the entire staging site including all of its data! Depending on the excluded table (e.g. _posts, _postmeta) this can lead to missing images and even layout elements.

B) Export first, orders and transactional data from the live site and import them into the staging site before migrating the staging site to live.
This allows you to copy over the entire staging site.

Note: Option B is better and saver!

 

To skip WooCommerce orders you need to exclude the tables below.

  • wpstg1_posts
  • wpstg1_postmeta
  • wpstg1_users
  • wpstg1_usermeta
    All tables beginning with:
  • wpstg1_woocommerce_

The huge drawback is that this also excludes posts and articles and any other data that is stored in the tables _posts and _postmeta on our WordPress site. For instance, WordPress stores menu entries and all other custom post type data in these tables as well.

Export & Import WooCommerce Orders

So the better option is to export first your orders and products data with a separate export/import plugin from the production site and then to import them into the staging site before you do the push.

There are several plugins to do that job.
One of them is the one by WebToffee

(If you know another reliable import/export plugin please let us know)

Keep in mind that exporting and importing orders will likely change the order id of most of the new orders due to the reason that the WooCommerce order id is the same as the post id which is a unique number in WordPress.

So if the post id on your staging site is already used, the imported order gets a new id which results in a new order id.

So if you like to keep the order id you need to use another plugin which adds a new database entry that stores the order id in a separate field that allows you to have that order id separated from the post id.

Before you push the staging site make sure to set your website into maintenance mode or to disable the shop system to make sure that no orders come in while you push data from the staging site to live.

Read also this ongoing in-depth and technical article about migrating WooCommerce orders from one site to another:

https://www.skyverge.com/blog/moving-woocommerce-orders-sites/

Before you export and import any orders from your live site to live it’s strongly recommended to create another staging site to test this whole process before you do the import and export on the real staging website!

 

See also: WooCommerce database table reference

Keywords: WP Staging + WooCommerce, WP Staging Exclude WooCommerce Orders, Exclude WooCommerce Products