Clean up auto-draft shop orders in WooCommerce

if ( ! function_exists( 'clean_up_wc_auto_draft_orders' ) ) {
	function clean_up_wc_auto_draft_orders() {
		foreach ( wc_get_orders( array( 'limit' => -1, 'post_status' => 'auto-draft', 'return' => 'ids' ) ) as $order_id ) {
			wp_delete_post( $order_id, true );
		}
	}
}
clean_up_wc_auto_draft_orders();

No comments yet.

Leave a Reply