Skip to content

Instantly share code, notes, and snippets.

@BKeanu1989
Created April 17, 2019 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BKeanu1989/89094f0151b0fd1f28afb6b022befa77 to your computer and use it in GitHub Desktop.
Save BKeanu1989/89094f0151b0fd1f28afb6b022befa77 to your computer and use it in GitHub Desktop.
<?php
function delete_orders() {
global $wpdb;
$order_ids = $wpdb->get_col("SELECT ID FROM {$wpdb->prefix}posts WHERE post_type = 'shop_order'");
foreach($order_ids AS $order_id) {
$order_id = (int) $order_id;
wp_delete_post($order_id, true);
}
}
delete_orders();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment