i want update order modified date using below code but it's not working (it's set current now date time).
Code:
$order = wc_get_order( 5029 );
$now = new DateTime();
$now->modify('-4 day');
$order->set_date_modified($now->getTimestamp());
$order->save();
woocommerce 7.9.0
Apparently you can't alter the modified date when using save()
method as this method overwrite itself the modified date, with the real "current" modified date.
So It requires a direct SQL query on the database related tables wp_posts
, wp_wc_orders
to alter the modified date.