I want to delete completed all orders in woocommerce by using a single my sql query. Because, I'm having a problem with my WordPress Dashboard
. I can't view the completed orders from the back-end. It's getting blank. I have 7,823 Completed Orders
. I hope that's why I seen white page when I'm going to view the Completed Orders
.
Is there have a way to, That I can delete all Completed Orders
using MySQL query. So, that I can run it in PHPMYADMIN
.
Have any suggestions.
If you need to clean up your WooCommerce order history, bulk deleting orders is a quick and easy way to do it. Simply navigate to the Orders page, select the orders you want to delete, and then click on the Bulk Actions > Delete menu item.
Are WooCommerce Orders Stored in the Database? Yes, they are stored in the wp_posts table. WooCommerce orders are a Custom Post Type (CPT) so they're located in the wp_posts table. If you search the post_type field for 'shop_order', your SQL query will retrieve all your WooCommerce orders.
You can specify multiple tables in a DELETE statement to delete rows from one or more tables depending on the condition in the WHERE clause. You cannot use ORDER BY or LIMIT in a multiple-table DELETE .
My solution would be just deleting all the orders (If you're moving from a shop with demo data to your new site). You can do this using the following SQL-queries.
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';
To use the native Woocommerce functionality by the maximum, you can do it following way. Move all orders to trash with SQL:
UPDATE wp_posts SET post_status = 'trash' WHERE post_type = 'shop_order';
And then go to Woocommerce -> Orders -> Trash and click Empty Trash.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With