One of the problems that most WordPress users have is bulk remove of all WooCommerce products at once. Suppose you own a store with more than 2000 thousand products and you want to delete all products or half of them for any reason. It is not surprising if you are looking for a solution to delete all products in the shortest possible time. The good news is that there are different ways to delete all WooCommerce products very quickly, and in this post, we are going to teach you how to do it.
How to prepare your website to delete all WooCommerce products?
Before you delete all products from WooCommerce stores, it is important to consider the possible consequences. First of all, note that removing all products will also target orders related to them. Another concern is the removal of product dependencies, which may not be your main goal of removing WooCommerce products.
To avoid these possible consequences, consider the following two points before removing all WooCommerce products:
Back up the site information before deleting all products
It is better to back up essential information such as WooCommerce orders, customer reviews, product images, and product dependencies.
Collect important information before removing all products
If your products are linked to other data such as customers, orders, or reviews, it is important to check for possible dependencies. For example, if you remove products that have already been purchased by customers. You may lose your loyal customers who used to visit your site to buy that product.
WooCommerce delete all products manually
The easiest way to bulk delete WooCommerce products is to remove them manually through the WooCommerce product bulk edit page. This is an efficient method for online stores with a relatively small volume of products.
First, go to the “Products » All Products” section in the WordPress dashboard.
By default, WooCommerce displays 20 products per page. If the number of products available on your site is more, find the screen options tab in the upper right corner and click on it.
Now, in the pagination section, set the “Number of items per page” option so that all the products you have are displayed on one page. Finally, click on “Apply”.
Now, all products can be viewed on one page and you can select them all by checking the checkbox under the bulk actions window. If you want to select only certain products, you have to check them one by one. Keep in mind that you can apply different filters to target specific products or product groups.
After selecting the products to be deleted, return to the “Bulk Actions” box and select the “Move to Trash” option. Then click on the Apply button.
It’s important to note that even though we’ve moved the products to the trash, they haven’t been completely removed yet. To complete the bulk delete process, go to “Trash” and again select all products through the checkbox and delete them.
Delete WooCommerce products from database via SQL
As you may notice, bulk remove products via WooCommerce product bulk edit manually, is very inefficient in online stores with a large number of products. Time is of the essence in web development, and wasting precious time ticking thousands of checkboxes is a tedious way to do it. Fortunately, this problem can be solved using code.
For delete all WooCommerce product via SQL, you must first enter your host Cpanel and go to “phpMyAdmin” as shown in the image below.
After entering “phpMyAdmin“, you will see the image below, where you can enter the name of your database from the left and then click on “wp-post” from the window that opens.
After entering this section, you will see the image below on the left side. Please note that in some Cpanels, there is a “Go” button on the right side of the image, and you can apply it by entering the desired code.
Otherwise, you have to click on “Console” and apply the code there and then press “Ctrl+Enter”.
To execute WooCommerce delete all products, you can enter one of the following codes according to your needs in this section:
Bulk delete all WooCommerce simple products
The following code is for deleting all WooCommerce simple products!
Copy and paste the following code in the indicated section and then press “Ctrl+Enter” and wait for the code to be applied.
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';
Bulk remove all WooCommerce products and categories
The following code is for deleting all related products and categories in WooCommerce.
Copy and paste the following code in the indicated section and then press “Ctrl+Enter” and wait for the code to be applied.
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';
DELETE pm FROM wp_postmeta pm LEFT JOIN wp_posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL;
delete from `wp_termmeta`
where
`term_id` in (
SELECT `term_id`
FROM `wp_term_taxonomy`
WHERE `taxonomy` in ('product_cat', 'product_type', 'product_visibility')
);
delete from `wp_terms`
where
`term_id` in (
SELECT `term_id`
FROM `wp_term_taxonomy`
WHERE `taxonomy` in ('product_cat', 'product_type', 'product_visibility')
);
DELETE FROM `wp_term_taxonomy` WHERE `taxonomy` in ('product_cat', 'product_type', 'product_visibility');
DELETE meta FROM wp_termmeta meta LEFT JOIN wp_terms terms ON terms.term_id = meta.term_id WHERE terms.term_id IS NULL;
DELETE FROM wp_woocommerce_attribute_taxonomies;
DELETE FROM wp_woocommerce_sessions;
WooCommerce delete all products with variations and taxonomies
The following code is for deleting all products with variations and taxonomies in WooCommerce.
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 IN ('product','product_variation'));
DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'));
DELETE FROM wp_posts WHERE post_type IN ('product','product_variation');
Bulk remove all WooCommerce product taxonomies
If you want to remove only the attributes, you can run the following code.
DELETE FROM wp_terms WHERE term_id IN (SELECT term_id FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%');
DELETE FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%';
DELETE FROM wp_term_relationships WHERE term_taxonomy_id not IN (SELECT term_taxonomy_id FROM wp_term_taxonomy);
After running each of these codes, go back to your WordPress dashboard and check if your products have been removed. If you get an error after running the SQL statement, make sure you’ve replaced all prefixes correctly with wp.
Note that the above code deletes all WooCommerce products. If you are not familiar with coding, be sure to back up your data or use the next method we are introducing which is using one of the best WooCommerce product bulk edit plugins.
How to use the WooCommerce product bulk edit plugin to bulk remove all products in your online store?
To bulk remove all WooCommerce products using the WooCommerce product bulk edit plugin, first download, install and launch the plugin, after activation, the plugin will be automatically added to the WordPress dashboard.
WooCommerce Products Bulk Edit Plugin
Then you can run this plugin to see the list of products displayed as a table. To bulk delete all products, you must first display all of them in the product table of this plugin. For this, just set the pagination box to 100.
Then mark the checkbox next to the ID option so that all products are selected.
After selecting the products, the “Delete” button will be displayed to you, if you click on it, you will see the following two options:
- Move to trash.
- Delete products permanently.
If you don’t want to delete all the products, click on the “Permanently” option. In this way, all the products are completely deleted and there is no possibility of restoring them.
But if you think that in the future you may need the products to be added to your store again, click on the “Move to Trash” option. In this way, the trash option is displayed on the top of the table, if you click on it, you will see the deleted products and you can restore them to your store whenever you want.
Conclusion
In WooCommerce store, the most important part is their products, and every online store tries to display and sell high-quality products for its users. In this article, we answered one of the most common questions of online store owners regarding the different methods useful for WooCommerce products bulk delete.
In general, you can remove your products from the store from your WooCommerce editor, through coding or using the bulk edit plugins. But WooCommerce product bulk edit plugin is the easiest and most reliable way to delete or edit products in bulk. We suggest you visit the demo of this plugin and get familiar with more features included in it.
WooCommerce Products Bulk Edit Plugin