For various reasons, sometimes we need to We delete all orders data over time on a Magazine online (Orders) created with WooCommerce.
content
The handy method of all is to select a column of commands in “WooCommerce” → “Orders” , then to “Bulk Action” to choose the option “Move to Trash” si click “Apply“.

After we click on “Apply“, orders will be moved to “Trash“.
What do we do when we have several hundred or thousands of commands that we want to delete from WooCommerce Orders?
In the example above, I have only one order, but when there are some Hundreds of orders in Woocommerce, you have two variants by which you can delete them.
1. Woocommerce Orders deletion from Dashboard.
Many WordPress and WooCommerce users ignore or do not see that at the top, somewhere in the right Dashboard is the option “Screen Options”.
from “Screen Options” We can choose that a larger number of orders be listed on the page. By default Woocommerce lists 25 orders, but from “Screen Options” We can choose at “Number of items per page” a larger number.
If you have a very large number of orders, it is good though not exceed 150 orders listed on the page. You can do a very large Load at the server and communication interruptions may occur with the host server both on the controls and their deletion. Errori nginx or httpd server.

After you click on “Apply” Refresh will automatically be given on the page and listed the number of WooCommerce Orders set by you.
2. WoCommerce delete delete from SQL
This method will move all commands in WooCommerce → Orders in “Trash“, where you can delete them with a single click.
First of all you make a backup at the database.
Go to Phpmyadmin, select the store database, and in SQL execute 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 we successfully execute the order from SQL, we go to the online store in Dashboard → WooCommerce → Orders → Trash and Click on “Empty Trash“.
If you have to delete a large number of commands from the basket, do not expect them to disappear after a single click on “Empty Trash”. It is very likely that the web page does not respond and the server error that disappears after a refresh. Resume the operation until the trash can “Orders” It will be empty.
Thanks for ‘2. Delete WooCommerce commands from SQL’! Useful when you have a ton of orders :)
thanks, that helped!
There would be no other elements to be deleted such as payments or associated comments?
But would it not be better to have a client database to be contacted?
On my site the oldest orders are automatically canceled.
How do I block this procedure instead and keep them forever?
Thank you.