Your Dedicated Partner for All Things WordPress

How to Delete All Products in WooCommerce

Table of Contents

Deleting all products in WooCommerce can be a time-consuming process. Sure, if the number of products is small, then it can be done via the WooCommerce panel manually. But most online stores have hundreds of products with different variations, custom taxonomies, and categories. Deleting such a large number of products manually is incredibly cumbersome. Let us take a look at different ways how you can delete WooCommerce products.

Deleting WooCommerce Products Manually

The simplest way of deleting WooCommerce products is by deleting them manually via your WordPress dashboard. It is an efficient method for online stores with a relatively small amount of products.

Start with locating the WooCommerce Products panel in your WordPress dashboard. It is located just underneath the WooCommerce tab. Click on it and you will be re-directed to the Products overview page.

WooCommerce products

By default, WooCommerce displays 20 products per page. If the amount of products in your case is higher, then locate the Screen Options tab in the upper right corner and click on it.

WooCommerce Screen options

Set the Number of Items Per Page option accordingly, so it would display all your products on a single page. Click the Apply button afterward to save changes.

WooCommerce number of items per page

Now, all products can be seen on a single page and you can select them all by ticking the checkbox underneath the Bulk Actions window. If you want to select only certain products, then you will have to tick them one by one. Keep in mind that you can apply different filters to target specific products or product groups.

WooCommerce products actions

After you have selected the products that need to be deleted, go back to the Bulk Actions window and select the Move to Thrash option. Then, click on the Apply button.

WooCommerce move to thrash

It is important to note that, even though we moved products to the Thrash, they have not been deleted. To complete the deletion process, go to the Thrash and either select all products via checkbox again and pick the Delete Permanently option in the Bulk Actions window, or just click on the Empty Thrash button next to the filter options.

WooCommerce delete permanently

Voilà! All WooCommerce products have been deleted. Remember to clear cache!

Deleting WooCommerce Products from Database via SQL

As we mentioned previously, deleting WooCommerce products manually in online stores with a large number of products is highly inefficient. In web development, time is of the essence, and wasting precious time ticking thousands of checkboxes is a tedious way of accomplishing this task. Thankfully, the issue can be remedied via the use of code.

Login to your phpMyAdmin account. Before proceeding, confirm that the script will be run on the correct database. In order to ratify whether the correct database is loaded, look for the table wp_options and check if it has the correct URL for your website. Always backup your website before running any script! Otherwise, you may lose significant data or even render the website inaccessible. You should regularly take precautions when running advanced SQL queries.

SQL

Now that you have located the SQL panel, select the wp_posts table and paste the code below. If your database prefix is not wp_, then replace it with the prefix you are using. Press the Go button to execute the SQL statement.

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’);

Go back to your WordPress dashboard and verify if your products are deleted. If you encountered an error after executing the SQL statement, then make sure you have replaced all the prefixes properly.

Additionally, if you want to delete just 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);

There are cases when you must do extensive work with databases. Creating posts, deleting posts, editing posts, et cetera. Every action influences the post metadata table and if you are not cautious, then you might end up with thousands of rows of data that is unused. By deleting orphaned post metadata (data that is affiliated with nonexistent posts), you will eliminate all records that have no use. In the same manner as before, run the following code.

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

Deleting WooCommerce products via Plugins

If you are not savvy with coding and databases in general, then consider using plugins. Unfortunately, there are not many plugins that can delete all WooCommerce products and their corresponding data. Although there are plugins that reset databases, not many of them have functionality for this specific task. Let us take a look at 3 popular plugins that can be used to delete all WooCommerce products.

WP Reset. The most popular plugin for resetting sites databases to the default installation values without modifying files. It is a fast and efficient way of targeting specific data and removing it. With multiple fail-safe mechanisms integrated into the plugin, you will be able to restore any data you have accidentally deleted. We advise you to carefully take a look at the documentation in order to understand how to select and target the data you desire.

Store Toolkit for WooCommerce. This plugin includes a growing set of commonly-used WooCommerce administration tools, mainly, aimed at web developers and store maintainers. With a large set of maintenance/debugging/clearing tools at your disposal, you will be able to delete any data concerning WooCommerce.

Smart Manager for WooCommerce. For the most part, this plugin is used to increase WooCommerce functionality and add additional tools for managing your store, but it can be used to clear your database from unnecessary products and their corresponding data. The plugin has a free(lite) version and a paid one.

Final Words

With the aforementioned methods, you will be able to delete WooCommerce products with relative ease. It is up to you to decide which procedure is better suited for your online store. Keep in mind that the simplest method might not always be the right one and vice versa. We wish you a bug-free journey through the world of e-commerce and stay tuned for more articles!

How to get started?

Learn more

WooCommerce Maintenance

Save 33% with our Annual pricing plan.

Get Started

Having Troubles With WordPress?

Claim Your Free WordPress Maintenance

In today’s fast-paced digital landscape, every website deserves the care and expertise of a professional maintenance team, ensuring optimal performance, enhanced security, and seamless user experiences, so you can focus on growing your business with peace of mind.

Alexey Seryapin
Founder of WPServices

Coupon Code Applied!

Take your time and continue browsing our services.

Alexey Seryapin
Founder of WPServices