skip to Main Content

WordPress i want to send sms when admin cancel order from backed
i can not find how to get order id in back-end using php file

2

Answers


  1. Get order details from order id
     $order = wc_get_order( $order_id );
    if ( $order ) {
           // Get Order ID and Key
        $order->get_id();
        $order->get_order_key();
    }
    
    Login or Signup to reply.
  2. By using the hook, You can directly send the mail.

    In function.php file add this code,

    add_action( 'woocommerce_order_status_cancelled', 'sent_custom_email', 21,1);
    function sent_custom_email( $order_id ) {
    $order = new WC_Order( $order_id ); 
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search