• Resolved rakesh1974

    (@rakesh1974)


    // Sending SMS to customers on new orders
    add_action('woocommerce_order_status_processing', 'custom_msg_customer_process_order', 10, 3);
    function custom_msg_customer_process_order ($order_id) {
    
    $order = new WC_Order( $order_id );
    $order_date = $order->get_date_created();
    $billing_phone = $order->get_billing_phone();
    
    $apiKey = urlencode('apikey');
    
    // Message details
    $numbers = array($billing_phone);
    $sender = urlencode('TXTCL');
    $message = rawurlencode('Thank you for buying from us, a Wellness product. Your order number $order_id Dated $order_date is confirmed.');
    
    $numbers = implode(',', $numbers);
    
    // Prepare data for POST request
    $data = array('apikey' => $apiKey, 'numbers' => $numbers, "sender" => $sender, "message" => $message);
    
    // Send the POST request with cURL
    $ch = curl_init('https://api.textlocal.in/send/');
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($ch);
    curl_close($ch);
    
    // Process your response here
    echo $response;
    }
    

    Trying to send sms to customer when a new order is placed, using the above integration SMS api code, but it is not working… Anyone has tried integrating it successfully, please let me know what could be the issue in the above code. This code is added at the end of child-theme-> functions.php

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello,

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack.

    Thread Starter rakesh1974

    (@rakesh1974)

    Hi,

    I got the SMS part working anyhow this time for new order processing…

    Now the new issue is that the order id and the order date is not reflected/captured in the message part…

    The SMS come to me as is in the $message:
    Thank you for buying from us, a Wellness product. Your order number $order_id Dated $order_date is confirmed.

    Question: why are the data variables not replaced with the actual data?

    thanks

    Hi @rakesh1974

    Your order number $order_id Dated $order_date is confirmed.

    I understand that now the problem is that the data variables not getting replaced with the actual data.

    However, please be informed that support for custom coding is beyond the scope of support we are able to provide in this forum. This particular forum is for questions that are related to the WooCommerce core features.

    For help with customization or coding, please reach out to the channels shared in our previous interaction.

    Additionally, for direct assistance with code customizations, we can also recommend consulting with the WooCommerce Customizations Partners. https://woocommerce.com/customizations/`

    Nevertheless, as mentioned above, we’re going to leave this thread open for a bit to see if anyone is able to chime in to help you out here.

    Cheers

    Seems we’ve not had additional inputs on this thread. Thus, we encourage you to make use of the above resources.

    I’ll go ahead and mark the thread as resolved but please feel free to create a new thread if you have further questions.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘SMS api integration’ is closed to new replies.