Skip to content

Instantly share code, notes, and snippets.

@m4munib
Last active October 13, 2018 08:44
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save m4munib/c51bbbadd390cd994e088bb73d04ba92 to your computer and use it in GitHub Desktop.
<?php
add_action('woocommerce_order_status_changed', 'mk_woocommerce_order_status_changed', 10, 4);
function mk_woocommerce_order_status_changed($order_id, $status_from, $status_to, $woo) {
mk_woocommerce_update_order_date($order_id);
}
function mk_woocommerce_update_order_date($order_id, $post_status) {
$oOrder = new WC_Order($order_id);
$order_data = $oOrder->get_data();
if (is_array($order_data)) {
if (isset($order_data['id'])) {
if ($order_data['id'] > 0) {
$time = current_time('mysql');
$args = array(
'post_id' => $order_data['id'],
'post_date' => $time,
'post_date_gmt' => get_gmt_from_date($time)
);
wp_update_post($args);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment