I'm using the custom order statuses plugin for custom order status.
our shop has 15 days return policy.
so, I want to change the order status "Delivered" to "Completed" after 15 days. it means when change status Delivered that time to 15 days later automatically changes order status to "Completed"
I tried the code below but not working for me.
function setCompletedAfter15Days(){
$orders = wc_get_orders( array(
'status' => 'delivered',
'date_created' => '<' . ( time() - 15 * DAY_IN_SECONDS ),
) );
foreach ($orders as $order){
$order->update_status( 'completed' );
}} wp_schedule_event( time(), 'daily', 'setCompletedAfter15Days' );