How to Properly Delete All WooCommerce Products

Step 1: Login to Your PhpMyAdmin

If you have more than one database, make sure you click on the correct database. If you’re not sure because you have more than one WordPress installation on the same domain, open a table and look for “wp_options”, you’ll be able to see the URL of the website you’re making changes to.

Step 2: Run the SQL Statement

If you are on the correct database, click on the SQL tab on the top right. It might be empty or have an SQL statement there from a previous command.

With it empty, copy and paste the following code:

DELETE relations.*, taxes.*, terms.*
FROM wp_term_relationships AS relations
INNER JOIN wp_term_taxonomy AS taxes
ON relations.term_taxonomy_id=taxes.term_taxonomy_id
INNER JOIN wp_terms AS terms
ON taxes.term_id=terms.term_id
WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type='product');
DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type = 'product');
DELETE FROM wp_posts WHERE post_type = 'product';

Press the “Go” button to execute the SQL statement.

Leave a Reply