07-26-2023, 08:48 PM
How can I get the old status and new status of an order using the WooCommerce hook: `woocommerce_order_status_changed`?
This is my code, but only the `$order_id` is filled..
add_action('woocommerce_order_status_changed','woo_order_status_change_custom');
function woo_order_status_change_custom($order_id,$old_status,$new_status) {
//order ID is filled
//old_status and new_status never
//tested by logging the parameters
}
Now I can easily get the new status using this code:
$order = new WC_Order( $order_id );
$orderstatus = $order->status;
But how can I get the previous order status, since `$old_status` is empty?
This is my code, but only the `$order_id` is filled..
add_action('woocommerce_order_status_changed','woo_order_status_change_custom');
function woo_order_status_change_custom($order_id,$old_status,$new_status) {
//order ID is filled
//old_status and new_status never
//tested by logging the parameters
}
Now I can easily get the new status using this code:
$order = new WC_Order( $order_id );
$orderstatus = $order->status;
But how can I get the previous order status, since `$old_status` is empty?