aniket patel
aniket patel

Reputation: 41

Woocommerce Paypal Order Status Not Changing

add_filter( 'woocommerce_payment_complete_order_status', 'status_after_order', 10, 2 );

function status_after_order( $order_status, $order_id ){
    echo $order_status;
}

When we ordered through paypal and admin can set Hold stock ( Woocommerce > Products > Inventory ). after time out order status automatically updated to "Cancelled" for Admin but when we use above filter it is showing "Processing".

Any filter/action that it will gives me status "Cancelled" in this case. Can you help me out of this problem?

Upvotes: 0

Views: 364

Answers (1)

kashalo
kashalo

Reputation: 3562

well, first the hook you are using is just for order complete status that's why you are not getting the order status.

however i don't know what exactly you want to do after detecting the order but you have two solution:

first solution is detect when the order status changed from whatever status to cancelled

add_action('woocommerce_order_status_cancelled', 'check_status', 30, 2);

function check_status($order_id)
{
    wp_die( $order_id ); // this will echo the id or you can do whatever you want here 

}

second solution is to check if the order has been changed from certain status to another by using this hook:

add_action('woocommerce_order_status_changed', 'check_status', 30, 3);

function test12($id, $old_status, $new_status)
{

    if ($new_status == 'cancelled') {
        //do Somthing
    }

}

Upvotes: 1

Related Questions