public static function trash_post($id) { global $wpdb; if ($id > 0) { $post_type = get_post_type($id); if (in_array($post_type, wc_get_order_types('order-count'))) { $refunds = $wpdb->get_results($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'shop_order_refund' AND post_parent = %d", $id)); foreach ($refunds as $refund) { $wpdb->update($wpdb->posts, array('post_status' => 'trash'), array('ID' => $refund->ID)); } delete_transient('woocommerce_processing_order_count'); wc_delete_shop_order_transients($id); } } }