Whereas we’re comfy declaring our experience in WordPress, it’s not with out challenges. One difficulty 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 frequent publish varieties used together with a short description of every:
- Product: Put up kind
productis used to retailer details about particular person merchandise in your WooCommerce retailer. This consists of product identify, value, description, and extra particulars.
- Product Variation: Put up kind
product_variationrepresents completely different product variations, equivalent to measurement or coloration choices. These are linked to the primary product.
- Order: Put up kind
shop_ordershops details about buyer orders, together with order standing, buyer particulars, and objects ordered.
- Order Refund: Put up kind
shop_order_refundtracks refunds related to particular orders.
- Coupon: Put up kind
shop_couponshops particulars about coupons and reductions that may be utilized to orders.
- Store Webhook: Put up kind
shop_webhookis 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 kind
shop_subscriptionIt’s related in case your retailer has subscription-based merchandise and shops details about buyer subscriptions.
- Store Subscription Renewal: Put up kind
shop_subscription_renewalis used to document subscription renewals.
- Store Subscription Change: Put up kind
shop_subscription_switchtracks adjustments or switches in subscription merchandise.
- Store Subscription Pending Cost: Put up kind
shop_subscription_pending_paymentrepresents subscription orders with pending funds.
- Store Subscription Failed: Put up kind
shop_subscription_failedis used to document failed subscription funds.
- Product Overview: Put up kind
product_reviewis used to retailer buyer evaluations for merchandise. Every evaluation is handled as a separate publish, together with reviewer data, evaluation textual content, and rankings for the related product.
In the event 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 atmosphere. 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 atmosphere that’s utilizing the identical incremental ID of 6702. There are a few points with this:
- Order IDs usually are not sequential. 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 by any means into the variety of orders you’ve fulfilled in your website.
- 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 an extra 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 unique ID in
wp_posts. Merchandise do that with an optionally available SKU subject, however it’s additionally not absolutely built-in with the platform to make the most of that as a major key.
I love the simplicity of this strategy to increasing the platform into commerce. That stated, I’m additionally shocked they didn’t go a step additional to resolve this difficulty. This implies there’s no easy strategy to take a staging atmosphere and synchronize it with manufacturing to go dwell with a brand new theme.
How To Resolve This
There’s a resolution to this, however 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 Information out of your Manufacturing Setting
Inside your manufacturing atmosphere, you’ll be able to export every of the vital publish 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 Information to your Staging Setting
After which you’ll be able to import that information within the default file format into your staging atmosphere, making certain that you simply don’t write over any present information within the database.
Step 3: Resolve Conflicting IDs
Because the plugin iterates by way of information to import, it is going to 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 document 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 learn 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. In the event you’re not involved with referencing older orders by ID, this selection makes the whole lot simpler. Nonetheless, in the event 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 info and all information have been efficiently imported. As soon as all the information conflicts have been resolved, I used to be in a position to push staging to manufacturing. A pleasant function of the plugin was that I didn’t should re-upload the import, I may simply rerun the import within the historical past tab.