skip to Main Content

Invoice information on the woocoommerce_thankyou page is curled by a web service. If the user does not see this page for any reason, how can the storage operation be performed? Can invoice storage action be changed in any other way?

add_action( 'woocommerce_thankyou', 'club_add_factor', 10, 1 );
function club_add_factor( $order_id ) {
if ( ! $order_id ) {
    return;
}
/* Get order info */
$order         = new WC_Order( $order_id );
$userID        = $order->get_customer_id();
$api           = new Club( $userID );
// something ...
}

2

Answers


  1. Chosen as BEST ANSWER

    Thanks bro ! I solved it with 'woocommerce_order_status_processing' action. I used it :

    add_action('woocommerce_order_status_processing', 'club_add_factor');
    

  2. You are right, "woocommerce_thankyou" handles the following hooks collectively. But when you are not landing on thankyou page, you can use on-hold or processing instead.

    //add_action('woocommerce_order_status_pending', 'club_add_factor');
    //add_action('woocommerce_order_status_on-hold', 'club_add_factor');
    //add_action('woocommerce_order_status_processing', 'club_add_factor');
    //add_action('woocommerce_order_status_completed', 'club_add_factor');
    
    add_action('woocommerce_thankyou', 'club_add_factor');
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search