How to quickly delete all orders (Orders) from WooCommerce [SQL Tips]

For various reasons, sometimes we need to we delete all commands data over time on a shop (Orders) created with WooCommerce.

The method available to all is to select a column of commands in "WooCommerce”→“Orders", Then to"Bulk Action"Choose the option"Move to Trash"And click"Apply".

After clicking on "Apply", Orders will be moved to"Trash".

What do we do when we have several hundreds or thousands of orders that we want to delete from WooCommerce Orders?

In the example above, I only have one order, but when there are a few hundreds of orders in WooCommerce, you have two options by which you can delete them.

1. Deleting WooCommerce Orders from Dashboard.

Many users WordPress and WooCommerce ignore or do not see that at the top, somewhere to the right of the Dashboard is the option "Screen Options".

From “Screen Options"We can choose to list a larger number of commands on the page. By default WooCommerce lists 25 orders, but from “Screen Options"We can choose to"Number of items per page”A larger number.
If you have a very large number of orders, it's still good do not exceed 150 orders listed on the page. A very high load can be made on the server and communication interruptions with the host server can occur both when listing commands and deleting them. Errorand NGINX or HTTPD Server.

WooCommerce Number of Orders per page

After clicking on "Apply” the page will automatically refresh and the number will be listed WooCommerce Orders set by you

2. Deleting orders WooCommerce from SQL

This method will move all commands from WooCommerceOrders in "Trash", Where you can delete them with a single click.

First of all, make a backup of the database.

Go to phpMyAdmin, select the store database, and in SQL run the command line below:

update wp_posts set post_status = 'trash' where post_type = 'shop_order';

4347 rows affected. (Query took 0.2114 seconds.)

The result returned in my case.

After successfully executing the command from SQL, we go to the online store in Dashboard → WooCommerce → Orders → Trash and click on “Empty Trash".

If you have a large number of commands to delete from the cart, don't expect them to disappear after a single click on "Empty Trash". It is very likely that the web page will not respond and a server error will occur which disappears after a refresh. Repeat the operation until the "Orders" trash is empty.

Passionate about technology, I enjoy writing on since 2006. I have a rich experience in operating systems: macOS, Windows, and Linux, as well as in programming languages and blogging platforms (WordPress) and for online stores (WooCommerce, Magento, PrestaShop).

How to » WordPress » How to quickly delete all orders (Orders) from WooCommerce [SQL Tips]

5 thoughts on "How do we quickly delete all orders from WooCommerce [SQL Tips]"

  1. Can I preserve the orders non sarebe meglio per avere un customer database da ricontattare?

    Nel mio site gli ordini più vecchi si cancellano automatically.
    Come faccio invece a bloccare questo procedure e conservarli per semper?

    Thank you.

Leave a Comment