Skip to content

Instantly share code, notes, and snippets.

@pmgarman
Created August 1, 2013 22:35
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pmgarman/6135967 to your computer and use it in GitHub Desktop.
Save pmgarman/6135967 to your computer and use it in GitHub Desktop.
How to find and delete orphaned product variations from WooCommerce sites.
DELETE o FROM `wp_posts` o
LEFT OUTER JOIN `wp_posts` r
ON o.post_parent = r.ID
WHERE r.id IS null AND o.post_type = 'product_variation'
SELECT * FROM `wp_posts` o
LEFT OUTER JOIN `wp_posts` r
ON o.post_parent = r.ID
WHERE r.id IS null AND o.post_type = 'product_variation'
@binodkalathil
Copy link

Now we have a built in WooCommerce option for this as described here: https://stackoverflow.com/a/46245440/1788684

WP Admin > Woocommerce > Status > Tools tab > Delete Orphaned variations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment