moebig
Member
OP
RAID is not backup
- Joined:
- Jul 2024
- Posts:
- 115
- From:
- Casablanca, Morocco
Wesh everyone ! Incha'allah your shops stay up this summer. I made a small plugin for staging WooCommerce without breaking le production orders — basically it skips wp_posts (and wp_postmeta) during sync, but keeps everything else. Le server حلو when you don't overwrite 50k orders by accident, you know ?
The trick is selective table exclusion. By default WP migration plugins grab everything ; mine hooks into pre_export and filters by post_type. Orders, refunds, coupons stay on live. Products, pages, themes come to staging.
Code is rough, GPL, on my git. Incha'allah someone finds it useful !
RAID 1: because paranoia pays
haroldgsm
Member
Grumpy Old Sysadmin
- Joined:
- May 2024
- Posts:
- 329
- From:
- Ohio, US
Back when WooCommerce still stored everything in posts, that would've been enough. Kids these days forget there are dedicated tables now. You need to skip wp_wc_orders, wp_wc_order_addresses, wp_wc_order_operational_data, and the lookup tables too. Twenty years in this business, I've seen three "minimal" staging plugins corrupt HPOS stores because they didn't account for the metadata split.
Mark my words, if WooCommerce ever finishes the migration, half the staging tools on the market will break overnight.
IPv4, IRC, and irssi — fight me
moebig
Member
OP
RAID is not backup
- Joined:
- Jul 2024
- Posts:
- 115
- From:
- Casablanca, Morocco
You skip wp_wc_orders too?
Wa akhi I updated the git yesterday ! Now it checks for HPOS tables and skips wp_wc_orders, wp_wc_order_addresses, wp_wc_order_operational_data. The lookup tables I leave alone because they rebuild themselves, no ?
You are right, I saw this on a client shop in Rabat. My old version was pre-HPOS, I admit. The new hook filters by table prefix + wc_order, so anything WooCommerce adds later should catch insha'allah.
Git has tags now, v1.0 is legacy, v2.0 is HPOS-aware.
RAID 1: because paranoia pays
haroldgsm
Member
Grumpy Old Sysadmin
- Joined:
- May 2024
- Posts:
- 329
- From:
- Ohio, US
The lookup tables I leave alone because they rebuild themselves
They do NOT rebuild themselves if you half-sync them. Wp_wc_order_stats gets foreign key constraints with the operational data table. You pull products and orders in the wrong sequence, you get orphaned rows and WooCommerce starts throwing "Invalid order" on the frontend.
I've had to repair three sites this year where a "smart" staging plugin left lookup tables in a split-brain state. The fix is always the same: truncate and let wc_admin_daily run, which means your client calls you at 9 AM because overnight reports are blank.
Skip them. All of them. Wp_wc_order_stats, wp_wc_order_product_lookup, wp_wc_order_tax_lookup, wp_wc_order_coupon_lookup. They regenerate from the order tables you aren't touching anyway.
IPv4, IRC, and irssi — fight me