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 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. Delete WooCommerce Orders from the Dashboard.
Many users WordPress and WooCommerce ignores or I don't see that at the top, somewhere to the right of the Dashboard is the "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.
After clicking on "Apply”Will automatically refresh the page and list the number of WooCommerce Orders you set.
2. Delete WooCommerce commands from SQL
This method will move all commands from WooCommerce → Orders 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 SQL command, 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.