Would you like to automatically delete old WooCommerce orders? Old orders might be redundant and consume memory in your database. So, it’s a wise move to remove all redundant orders from the WordPress database. You can manually delete the old orders, but it takes time and is a hassle every day for you.
Let’s use the plugin for this. It’s a simple, set and forget WordPress plugin with no bloat whatsoever.
Get Started with WC Auto Delete Old Orders Plugin now. It automatically takes control of the old orders. You just install and the plugin takes your care.
Pricing
- Lifetime Updates
- 1 year of support
- 1 Site
- 7 days money-back guarantee *
* 100% refund when the product had a bug/problem I couldn’t resolve.
* Checkout and Payment are processed from Freemius – the reseller of the plugin.
Have pre-sale questions? Contact Me.
How does the plugin work?
The plugin automatically deletes old orders (orders older than 30 months by default, customizable in Settings). It uses the Action Scheduler to schedule the deletion. Every hour it checks if any order is older than 30 days (or specified in settings). Then it deletes 10 orders in an hour if there are so many old orders. So, you won’t be facing timeout in case of large number of orders.
You can see the tasks in Tools > Scheduled Actions, search for “wc_delete_old_orders_process”.
Settings
In the WooCommerce > Settings > General, you can set how many months old orders you want to get automatically deleted.
That’s all. If you like this plugin, checkout my other plugins.
I’m using the plugin, but it only deletes 3 orders per action.
How should I delete all orders for these 3 months?
Hi Carlos, if you have so many old orders, the PHP script will time out before it could delete all order at once. Maybe you can just run the process in a 5 minutes interval than in a day?
Hope that will help!
hi? how are you?
i need help trying to implement this code to bookings of woocommerce
”
heres is the code:
”
public function process_delete() {
if ( ! function_exists( ‘get_wc_booking’ ) ) {
return;
}
$args = array(
‘date’ => ‘update_status(‘completed’);
\wp_update_post( $booking ->get_id() );
}
}
}
“”
and this is the order code thats work
“”
public function process_delete() {
if ( ! function_exists( ‘wc_get_orders’ ) ) {
return;
}
$args = array(
‘date_created’ => ‘update_status(‘completed’);
\wp_delete_post( $order->get_id() );
}
}
“”
I don’t know what’s wrong, if it’s a misspelled function or what.
Hi Julian, thanks for reaching out. Unfortunately, it’s hard to debug without details on the booking plugin you’re using.