Set order date before changing order status.

This commit is contained in:
Nicolae Vartolomei 2015-09-22 12:02:29 +03:00
parent e075552604
commit dd62484cc2
1 changed files with 4 additions and 5 deletions

View File

@ -450,17 +450,16 @@ class WC_Meta_Box_Order_Data {
$date = strtotime( $_POST['order_date'] . ' ' . (int) $_POST['order_date_hour'] . ':' . (int) $_POST['order_date_minute'] . ':00' ); $date = strtotime( $_POST['order_date'] . ' ' . (int) $_POST['order_date_hour'] . ':' . (int) $_POST['order_date_minute'] . ':00' );
} }
$date = date_i18n( 'Y-m-d H:i:s', $date );
$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_date = %s, post_date_gmt = %s WHERE ID = %s", $date, get_gmt_from_date( $date ), $post_id ) );
// Order data saved, now get it so we can manipulate status // Order data saved, now get it so we can manipulate status
$order = wc_get_order( $post_id ); $order = wc_get_order( $post_id );
// Order status // Order status
$order->update_status( $_POST['order_status'], '', true ); $order->update_status( $_POST['order_status'], '', true );
// Finally, set the date
$date = date_i18n( 'Y-m-d H:i:s', $date );
$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_date = %s, post_date_gmt = %s WHERE ID = %s", $date, get_gmt_from_date( $date ), $post_id ) );
wc_delete_shop_order_transients( $post_id ); wc_delete_shop_order_transients( $post_id );
} }
} }