skip to Main Content

I’m using Woocommerce in my project, I’m trying to call an API every time order status changes from “pending payment” to “processing”.
I’m looking for an action to do that.

2

Answers


  1. You can use “woocommerce_order_status_changed” hook as below,

    $this_get_id : Order ID

    $this_status_transition_from : Order status changing from

    $this_status_transition_to : Order status changing to

    $instance : Order object instance

    add_action('woocommerce_order_status_changed','action_woocommerce_order_status_changed',10, 4 );
    function action_woocommerce_order_status_changed( $this_get_id, $this_status_transition_from, $this_status_transition_to, $instance ) { 
        // your code
    }
    
    Login or Signup to reply.
  2. try using this code:

    function mysite_processing($order_id) {
        //your api call here
    }
    add_action( 'woocommerce_order_status_processing', 'mysite_processing');
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search