Whereas we’re comfy declaring our experience in WordPress, it’s not with out challenges. One situation 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 submit sort categorizes them. Right here’s a listing of some frequent submit varieties used together with a quick description of every:
- Product: Put up sort
product
is used to retailer details about particular person merchandise in your WooCommerce retailer. This contains product title, value, description, and extra particulars. - Product Variation: Put up sort
product_variation
represents completely different product variations, corresponding to measurement or shade choices. These are linked to the principle product. - Order: Put up sort
shop_order
shops details about buyer orders, together with order standing, buyer particulars, and gadgets ordered. - Order Refund: Put up sort
shop_order_refund
tracks refunds related to particular orders. - Coupon: Put up sort
shop_coupon
shops particulars about coupons and reductions that may be utilized to orders. - Store Webhook: Put up sort
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: Put up sort
shop_subscription
It’s related in case your retailer has subscription-based merchandise and shops details about buyer subscriptions. - Store Subscription Renewal: Put up sort
shop_subscription_renewal
is used to report subscription renewals. - Store Subscription Swap: Put up sort
shop_subscription_switch
tracks modifications or switches in subscription merchandise. - Store Subscription Pending Cost: Put up sort
shop_subscription_pending_payment
represents subscription orders with pending funds. - Store Subscription Failed: Put up sort
shop_subscription_failed
is used to report failed subscription funds. - Product Evaluation: Put up sort
product_review
is used to retailer buyer evaluations for merchandise. Every assessment is handled as a separate submit, together with reviewer data, assessment textual content, and scores for the related product.
In the event you’re designing or implementing a brand new theme for WordPress, you usually push a duplicate of the location and database to a staging or native growth surroundings. In the meantime, the location continues to gather orders and different ecommerce relevant occasions.
Database Conflicts in wp_posts
In different phrases, information are being created in manufacturing that may battle with them. Instance: You add a brand new web page on staging and the following incremental ID is 6702. Nonetheless, there’s an order in your manufacturing surroundings that’s utilizing the identical incremental ID of 6702. There are a few points with this:
- Order IDs will not be sequential. If in case you have one order that’s 5 after which construct 3 pages, your subsequent order ID is 9. Viewing your order ID provides you no perception in any way into the variety of orders you’ve fulfilled in your website.
- Order IDs cannot 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 area for orders that’s each sequential and distinctive, however differed from their inside ID. In different phrases, ID 6702 might have been bill 4322… and simply added between databases with a special ID in wp_posts
. Merchandise do that with an non-obligatory SKU area, nevertheless it’s additionally not totally built-in with the platform to make the most of that as a main key.
I love 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 situation. This implies there’s no easy option to take a staging surroundings and synchronize it with manufacturing to go reside with a brand new theme.
How To Resolve This
There’s a resolution 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 Surroundings
Inside your manufacturing surroundings, you possibly can export every of the essential submit varieties. It’s also possible to make the most of superior filtering… like using the final order date in your staging space to solely embrace orders after your information went out of sync.
Step 2: Import Present Order Knowledge to your Staging Surroundings
After which you possibly can import that information within the default file format into your staging surroundings, making certain that you just don’t write over any present information within the database.
Step 3: Resolve Conflicting IDs
Because the plugin iterates via information to import, it’ll 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 report it was. If it was a web page or submit, I simply copied these to make sure they utilized a brand new ID. If it was one thing else, I needed to decide easy methods to take care of it.
NOTE: There’s an choice with the plugin to replace the conflicting Order ID to a brand new Order ID. In the event you’re not involved with referencing older orders by ID, this feature makes every thing simpler. Nonetheless, in case you’re trying to help clients, you’ll must seek for their order utilizing one thing apart 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 all the information conflicts had been resolved, I used to be capable of push staging to manufacturing. A pleasant characteristic of the plugin was that I didn’t must re-upload the import, I might simply rerun the import within the historical past tab.