Home > Net >  Wordpress admin order Details Page how to get order id in php File?
Wordpress admin order Details Page how to get order id in php File?

Time:02-24

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

CodePudding user response:

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();
}

CodePudding user response:

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 ); 
}
  • Related