I need to change all orders with status wc-processing to status wc-completed on a especific day of the week and speficific hour.
I’m trying to schedule every Thursday an automatic order status change, from processing to completed.
This is what I found, a snippet that doesn’t work in my case, what’s wrong?
$is_week_days = in_array( date('w'), array( 4 ) ) ? true : false; // Thursday
$start_time = mktime( '23', '58', '00', date('m'), date('d'), date('Y') ); // 23:58pm
$end_time = mktime( '23', '59', '00', date('m'), date('d'), date('Y') ); // 23:59pm
$now_time = time();
if ( $is_week_days && ( $now_time >= $start_time && $now_time <= $end_time ) && $status != "wc-processing" ) {
$order->update_status( 'wc-completed' );
return;
}