Integrating SMS api with woocommerce , Not sending messages

前端 未结 5 779

I\'m integrating SMS API with WooCommerce to send automatic order updates to customers mobiles whenever the make any purchase on site.

below is my code for the same<

5条回答
  •  臣服心动
    2021-01-01 08:28

    Tested and working Custom api Integration with Woocommerce wordpress

    Ufone pakistan sms integration with woocommerce wordpress

    if you are looking for integration with ufone pakistan sms api bsms ufone pakistan service provider with woocommerce wordpress then use the following code in your functions file

    sms api integration ufone bsms with wordpress woocommerce thanks to the author on this page Integrating custom SMS API with woocommerce

    //add this line for calling your function on creation of order in woocommerce 
    add_action('woocommerce_order_status_processing', 'custom_func', 10, 3);
    
    function custom_func ($order_id) {
    
    $order_details = new WC_Order($order_id);
    
    //fetch all required fields
    $billing_phone = $order_details->get_billing_phone();
    $billing_name = $order_details->get_billing_first_name();
    $billing_last_name = $order_details->get_billing_last_name();
    $total_bill = $order_details->get_total();
    
    $textmessage = rawurlencode("Dear $billing_name, Thank you for your order. Your order #$order_id is being processed. Please wait for confirmation call Total Bill = $total_bill");
    
    // Now put HTTP ufone BSMS API URL
    $url = "https://bsms.ufone.com/bsms_v8_api/sendapi-0.3.jsp?id=msisdn&message=$textmessage&shortcode=SHORTCODE&lang=English&mobilenum=$billing_phone&password=password&messagetype=Nontransactional";
    
    // 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;
    }
    

提交回复
热议问题