SMS api integration
-
// 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)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘SMS api integration’ is closed to new replies.