Whereas we’re comfy declaring our experience in WordPress, it’s not with out challenges. One challenge that’s fairly irritating is the database structure utilized for WooCommerce. Particularly, varied information are saved within the wp_posts
desk in WordPress, and their publish kind categorizes them. Right here’s a listing of some widespread publish varieties used together with a short description of every:
- Product: Publish kind
product
is used to retailer details about particular person merchandise in your WooCommerce retailer. This consists of product identify, value, description, and extra particulars. - Product Variation: Publish kind
product_variation
represents totally different product variations, comparable to dimension or colour choices. These are linked to the principle product. - Order: Publish kind
shop_order
shops details about buyer orders, together with order standing, buyer particulars, and gadgets ordered. - Order Refund: Publish kind
shop_order_refund
tracks refunds related to particular orders. - Coupon: Publish kind
shop_coupon
shops particulars about coupons and reductions that may be utilized to orders. - Store Webhook: Publish kind
shop_webhook
is used for storing data associated to webhooks, which can be utilized to set off actions in response to occasions in your WooCommerce retailer. - Store Subscription: Publish kind
shop_subscription
It’s related in case your retailer has subscription-based merchandise and shops details about buyer subscriptions. - Store Subscription Renewal: Publish kind
shop_subscription_renewal
is used to file subscription renewals. - Store Subscription Change: Publish kind
shop_subscription_switch
tracks adjustments or switches in subscription merchandise. - Store Subscription Pending Cost: Publish kind
shop_subscription_pending_payment
represents subscription orders with pending funds. - Store Subscription Failed: Publish kind
shop_subscription_failed
is used to file failed subscription funds. - Product Evaluate: Publish kind
product_review
is used to retailer buyer critiques for merchandise. Every evaluate is handled as a separate publish, together with reviewer data, evaluate textual content, and scores for the related product.
When you’re designing or implementing a brand new theme for WordPress, you sometimes push a replica of the positioning and database to a staging or native improvement setting. In the meantime, the positioning continues to gather orders and different ecommerce relevant occasions.
Database Conflicts in wp_posts
In different phrases, information are being created in manufacturing that can battle with them. Instance: You add a brand new web page on staging and the subsequent incremental ID is 6702. Nonetheless, there’s an order in your manufacturing setting that’s utilizing the identical incremental ID of 6702. There are a few points with this:
- Order IDs are usually not sequential. When you’ve got one order that’s 5 after which construct 3 pages, your subsequent order ID is 9. Viewing your order ID provides you no perception by any means into the variety of orders you’ve fulfilled in your web site.
- Order IDs can’t be modified! WooCommerce makes use of that ID and communicates it on to your buyer in all subsequent invoices and order references.
It’s fairly troubling that WooCommerce engineers didn’t make the most of a further subject for orders that’s each sequential and distinctive, however differed from their inside ID. In different phrases, ID 6702 may have been bill 4322… and simply added between databases with a distinct ID in wp_posts
. Merchandise do that with an non-compulsory SKU subject, nevertheless it’s additionally not absolutely built-in with the platform to make the most of that as a main key.
I like the simplicity of this method to increasing the platform into commerce. That mentioned, I’m additionally shocked they didn’t go a step additional to resolve this challenge. This implies there’s no easy method to take a staging setting and synchronize it with manufacturing to go reside with a brand new theme.
How To Resolve This
There’s a answer to this, nevertheless it’s not a easy one. Import Export Suite for WooCommerce is the answer I’ve used and it makes this a way more manageable course of.
Step 1: Export Present Order Knowledge out of your Manufacturing Atmosphere
Inside your manufacturing setting, you may export every of the crucial publish varieties. You may as well make the most of superior filtering… like using the final order date in your staging space to solely embody orders after your knowledge went out of sync.
Step 2: Import Present Order Knowledge to your Staging Atmosphere
After which you may import that knowledge within the default file format into your staging setting, guaranteeing that you simply don’t write over any present knowledge within the database.
Step 3: Resolve Conflicting IDs
Because the plugin iterates by information to import, it can report whether or not or not there are any conflicts on particular IDs. That is when it will get a bit tougher.
Connecting on to the MySQL database, I needed to seek for these IDs within the wp_posts
desk to determine what sort of file it was. If it was a web page or publish, I simply copied these to make sure they utilized a brand new ID. If it was one thing else, I needed to decide find out how to take care of it.
NOTE: There may be an possibility with the plugin to replace the conflicting Order ID to a brand new Order ID. When you’re not involved with referencing older orders by ID, this feature makes every little thing simpler. Nonetheless, in case you’re seeking to help clients, you’ll have to seek for their order utilizing one thing aside from the ID!
As soon as I eradicated all conflicts, I re-imported the information and all information had been efficiently imported. As soon as the entire knowledge conflicts had been resolved, I used to be in a position to push staging to manufacturing. A pleasant characteristic of the plugin was that I didn’t must re-upload the import, I may simply rerun the import within the historical past tab.