wickywills
2/22/2017 - 8:58 AM

Clear out existing product data from Woocommerce

Clear out existing product data from Woocommerce

Source: http://www.support.m1creative.org/knowledgebase/how-do-you-delete-all-products-from-woocommerce/

DELETE p FROM wp_posts p WHERE p.post_type = 'product';

DELETE pm FROM wp_postmeta pm LEFT JOIN wp_posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL;

DELETE tr FROM wp_term_relationships tr INNER JOIN wp_term_taxonomy tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id) WHERE tt.taxonomy != 'link_category' AND tr.object_id NOT IN ( SELECT ID FROM wp_posts );