Вот моя попытка кода:
Код: Выделить всё
add_action( 'admin_footer', 'auto_trash_old_completed_orders_345erhwe546' );
function auto_trash_old_completed_orders_345erhwe546() {
global $nm_theme_options;
if ( isset( $nm_theme_options['delete_all_woo_orders_older_then_3_months'] ) && $nm_theme_options['delete_all_woo_orders_older_then_3_months'] == 1 ) {
// Theme option is set to delete old orders
$completed_order_ids = wc_get_orders( array(
'limit' => 100, // By batch of 100 orders
'status' => 'completed',
'return' => 'ids',
'date_created' => '
Подробнее здесь: [url]https://stackoverflow.com/questions/78434534/auto-delete-completed-orders-older-than-3-months-in-woocommerce-with-hpos[/url]