Reset WooCommerce: Delete All Products, Attributes and Categories with SQL
Sometimes you need to completely reset your WooCommerce store — for example, when testing imports, starting fresh with new product data, or cleaning up a staging site. WooCommerce itself doesn’t provide a one-click reset option for products, attributes, and categories.
In this tutorial, we’ll show you how to use SQL queries to safely remove all products, product attributes, and categories directly from the WordPress database.
Why Reset WooCommerce with SQL?
Quick and clean database reset (instead of manual bulk deletes).
Ideal for staging or development environments.
Useful when replacing supplier product feeds or fixing broken imports.
Code Snippet
Add these SQL queries in your database (via phpMyAdmin or wp db query).
⚠️ Important: Always take a full database backup before running destructive queries.
DELETE p, pm, tr
FROM XvvIa4v_posts AS p
LEFT JOIN XvvIa4v_postmeta AS pm ON p.ID = pm.post_id
LEFT JOIN XvvIa4v_term_relationships AS tr ON p.ID = tr.object_id
WHERE p.post_type IN ('product', 'product_variation');
DELETE t, tt, tr
FROM XvvIa4v_terms AS t
JOIN XvvIa4v_term_taxonomy AS tt ON t.term_id = tt.term_id
LEFT JOIN XvvIa4v_term_relationships AS tr ON tt.term_taxonomy_id = tr.term_taxonomy_id
WHERE tt.taxonomy LIKE 'pa_%';
DELETE t, tt, tm
FROM XvvIa4v_terms AS t
INNER JOIN XvvIa4v_term_taxonomy AS tt ON t.term_id = tt.term_id
LEFT JOIN XvvIa4v_termmeta AS tm ON t.term_id = tm.term_id
WHERE tt.taxonomy = 'product_cat';
How It Works
The first query deletes all WooCommerce products and variations, including their metadata and taxonomy relationships.
The second query removes all product attributes (
pa_color,pa_size, etc.).The third query deletes all product categories along with their metadata.
After running these queries, your WooCommerce store will have:
✅ No products
✅ No attributes
✅ No categories
Best Practices
💾 Always back up your database before running SQL queries.
🧪 Test on a staging environment first.
🛠️ Replace
XvvIa4v_with your actual table prefix (checkwp-config.php).🔄 Use these queries when you need a full WooCommerce reset, not for regular maintenance.