Created
May 25, 2022 13:32
-
-
Save runezero/7d9ace6234efc14efbac16fdffc11e7a to your computer and use it in GitHub Desktop.
[Delete orders] Delete WooCommerce orders older than 6 months executable #woocommerce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action('admin_init', function(){ | |
| $args = array( | |
| 'date_created' => '<' . ( time() - (3600*24*31*6) ), | |
| 'limit' => 1000 | |
| ); | |
| $orders = wc_get_orders( $args ); | |
| foreach ($orders AS $order) { | |
| wp_delete_post($order->get_id(), true); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment