如何在订单状态为暂停和待付款时发送短信

时间:2018-06-12 08:02:13

标签: woocommerce status

我已使用此代码,除了on_hold和待付款之外,它正在处理其他状态 请帮忙

//DYNAMIC ORDER MSG TO CUSTOMER 

`add_action('woocommerce_order_status_on_hold',` `'custom_msg_customer_on_hold_order', 10, 3);`

function custom_msg_customer_on_hold_order ($order_id) {
    //Lets get data about the order made
    // Get an instance of the WC_Order object

    $order = new WC_Order($order_id);
    global $wpdb;
    $item = $wpdb->get_var("SELECT `order_item_name` FROM `wp_woocommerce_order_items` WHERE `order_id`=$order_id AND `order_item_type`='line_item'");

    //Now will fetch billing phone
    $billing_phone = $order->get_billing_phone();
    $billing_name = $order->get_billing_first_name();

    $textmessage = rawurlencode("Dear $billing_name, Thank you for your order. Your order #$order_id,$item is being processed. Please wait for confirmation call.");

    // Now put HTTP SMS API URL
    $url = "XXXXXXXXXXXXXXXXXXX&numbers=9994571735,$billing_phone&route=2&message=$textmessage&sender=RMJMRM";

    // NOW WILL CALL FUNCTION CURL  
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_URL, $url);
    $data = curl_exec($ch);
    $err = curl_error($ch);
    curl_close($ch);

    return $order_id;
}

我已将此代码用于其他状态,请帮助我处理on_hold和待处理付款状态

0 个答案:

没有答案