how to clear all products woocommerce keep category

Solutions on MaxInterview for how to clear all products woocommerce keep category by the best coders in the world

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
pinned-register now
showing results for - "how to clear all products woocommerce keep category"
Jax
04 Aug 2016
1-- Delete all WooCommerce products
2DELETE FROM wp_term_relationships WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'));
3DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'));
4DELETE FROM wp_posts WHERE post_type IN ('product','product_variation');
5
6-- Delete orphaned postmeta
7DELETE pm FROM wp_postmeta pm
8LEFT JOIN wp_posts wp ON wp.ID = pm.post_id
9WHERE wp.ID IS NULL
10