How to Bulk Delete Products or Orders Quickly in WooCommerce?

In WooCommerce, there are thousand elements listed. Some of these elements are WooCommerce products, categories, orders, tags, coupons, custom fields, etc. However, amongst all these elements, it becomes difficult to “Bulk Edit > Delete” in the WordPress dashboard. So, in this article, you will find how to bulk delete products or orders quickly. 

As said above, it seems hard to use the “Bulk Edit > Delete” option. At times, your website couldn’t process such big data. Or else, deleting products or orders manually 100 or 1000 times is never easy! In short, it is a cost & time consuming task.

WooCommerce data is always stored in the WordPress database. So, the good news is that you can create a “SQL DELETE statement”. So, using the SQL DELETE statement, you can bulk delete any products or orders. No doubt, you can face side-struggles when you perform this process on a live website. However, it is good to learn how it works. 

Get access to Your Website Database

Firstly, you can access database through phpMyAdmin. Also, one can check it out through cPanel. Check out our below guide to access database in cPanel.

How to Install WordPress on cPanel manually?

Further, you need to choose the database from left. Note down the ‘database tables prefix’ soon after the tables get listed in the right panel. The prefix is “wp_” in most cases, however it can also be different.  

Image showing database table prefix in phpMyAdmin

Thereafter, you need to write a DELETE statement in the SQL tab. It is the next step to Bulk Delete Products or Orders. I have listed the DELETE statements below. You can choose anyone based on what you want to delete. However, do not forget to erase “wp_” occurrences in the WordPress database table prefix. 

Image showing database  to bulk delete products or orders

  1. Bulk Delete Orders

DELETE FROM wp_woocommerce_order_itemmeta;
DELETE FROM wp_woocommerce_order_items;
DELETE FROM wp_comments WHERE comment_type = 'order_note';
DELETE FROM wp_postmeta WHERE post_id IN ( SELECT ID FROM wp_posts WHERE post_type = 'shop_order' );
DELETE FROM wp_posts WHERE post_type = 'shop_order';

2. Bulk Delete Products

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';

3. Bulk Delete Trash Product Items

DELETE FROM wp_postmeta WHERE post_id IN ( SELECT ID FROM wp_posts WHERE post_type = 'product' AND post_status = 'trash' );
DELETE FROM wp_posts WHERE post_type = 'product' AND post_status = 'trash';

4. Bulk Delete Coupons

DELETE FROM wp_postmeta WHERE post_id IN ( SELECT ID FROM wp_posts WHERE post_type = 'shop_coupon' );
DELETE FROM wp_posts WHERE post_type = 'shop_coupon';

5. Bulk Delete Order Notes

DELETE FROM wp_commentmeta WHERE comment_id IN ( SELECT ID FROM wp_comments WHERE comment_type = 'order_note' );
DELETE FROM wp_comments WHERE comment_type = 'order_note';

Also Read, How to delete “Uncategorized” Product Category in WooCommerce permanently?

How to enable WooCommerce Conditionally Hide Widgets function?

Important links: WooCommerce – https://woocommerce.com/

phpMyAdmin – https://www.phpmyadmin.net/