Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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