Quick answer
We don't make a WordPress or WooCommerce plugin, and you don't need one. One must-use plugin file (below) hooks into woocommerce_order_status_changed, queues the SMS with Action Scheduler so checkout never waits, sends it through our SMS API with wp_remote_post, and writes the result as an order note. Before it can send, your business needs DLT registration and an approved template for each message; the eight texts on this page are ready to register on your own DLT entity. Each SMS costs ₹0.15–₹0.20 plus GST, billed per delivered message.
How the order SMS works
- An order changes statusAt checkout, when a payment arrives, or when you change the status in the admin. WooCommerce fires
woocommerce_order_status_changed. - The SMS is queued, not sentThe snippet adds a job to Action Scheduler, the background queue that ships with WooCommerce. Checkout and the admin screen carry on without waiting for the SMS API.
- The queue sends itA moment later the job builds the text from the order, normalises the billing phone to
+91and 10 digits, and calls the API with a 15-second timeout. - The result goes on the orderA private order note records the message ID or the reason it failed, and a per-order flag makes sure the same status is never messaged twice.
Out of the box it maps WooCommerce statuses to messages like this. You can change the map in the file.
| Order status | SMS sent |
|---|---|
| On hold | Order placed, awaiting payment (for example bank transfer) |
| Processing | Payment received; for cash-on-delivery orders, COD confirmed |
| Shipped* | Shipped, with the tracking link |
| Out for delivery* | Out for delivery |
| Completed | Delivered |
| Cancelled | Cancelled |
| Refunded | Refunded |
What you need first
- WooCommerce, which includes Action Scheduler, and a way to upload files to
wp-contentand editwp-config.php(SFTP or your host's file manager). - An API key. Sign up at whitelabled.securesmsc.com/register and create a key under API & Integrations → API Management.
- DLT registration for your business: a principal entity, a 6-character header (sender ID) such as
ACMEST, and a template for every message below. See the DLT registration guide.
Lock the key to your store's server. The first IP address that uses a key successfully is added to that key's allowed list, and calls from any other IP then fail with HTTP 403 "IP address not allowed". Create a separate key for the store and don't try it from your laptop first. If your host can change your server's outgoing IP, or you run more than one server, ask your host for the outbound IP addresses and add them, or an IPv4 CIDR range, under API Management → IP Whitelisting before the first order.
Get a free API key + 100 test SMS. Create an account and generate an API key straight away. Verified businesses also get 100 free test SMS once KYC and DLT mapping are done. No setup fee, no minimum top-up, and credits never expire.
Install the order SMS snippet
Step 1: put the key in wp-config.php
Add these two lines to wp-config.php, above the line that says "That's all, stop editing!". Keeping the key there keeps it out of the database and out of your theme.
define( 'OSS_SMS_API_KEY', 'paste-your-api-key-here' );
define( 'OSS_SMS_SENDER_ID', 'ACMEST' ); // your approved 6-character DLT headerStep 2: add the must-use plugin
Create the folder wp-content/mu-plugins if it doesn't exist, and save this file in it as oss-order-sms.php. WordPress loads every file in that folder automatically: there is nothing to activate, it can't be switched off by mistake on the Plugins screen, and it keeps working when you change theme (unlike code in functions.php). Then change the texts in OSS_SMS_TEXTS to your approved templates.
<?php
/**
* Plugin Name: Order SMS via OnlineSMSService
* Description: Sends the customer an SMS when a WooCommerce order changes status.
* Version: 1.0.0
* Requires PHP: 7.4
*
* Save as wp-content/mu-plugins/oss-order-sms.php (create the mu-plugins folder if
* it doesn't exist). Then add two lines to wp-config.php, above "stop editing":
*
* define( 'OSS_SMS_API_KEY', 'paste-your-api-key-here' );
* define( 'OSS_SMS_SENDER_ID', 'ACMEST' ); // your approved 6-character DLT header
*/
defined( 'ABSPATH' ) || exit;
// 1. Which SMS goes out for which order status. "shipped" and "out-for-delivery" exist
// only if a plugin or your theme adds those statuses. Delete lines you don't want.
const OSS_SMS_STATUS_MAP = [
'on-hold' => 'order_placed', // e.g. bank transfer, awaiting payment
'processing' => 'payment_received', // cash-on-delivery orders get 'cod_confirmed'
'shipped' => 'shipped',
'out-for-delivery' => 'out_for_delivery',
'completed' => 'delivered',
'cancelled' => 'cancelled',
'refunded' => 'refunded',
];
// 2. The texts. Each must match a DLT template approved for your header, word for word.
// {name}, {order} and {url} are filled in from the order.
const OSS_SMS_TEXTS = [
'order_placed' => 'Hi {name}, we have received your order {order} at Acme Store. We will confirm it once the payment is received. -Acme Store',
'payment_received' => 'Hi {name}, we have received the payment for your order {order}. We will SMS you when it ships. -Acme Store',
'cod_confirmed' => 'Hi {name}, your cash on delivery order {order} at Acme Store is confirmed. Please pay when it is delivered. -Acme Store',
'shipped' => 'Your Acme Store order {order} has been shipped. Track it here: {url} -Acme Store',
'out_for_delivery' => 'Hi {name}, your Acme Store order {order} is out for delivery today. -Acme Store',
'delivered' => 'Hi {name}, your Acme Store order {order} has been delivered. Thank you for shopping with us. -Acme Store',
'cancelled' => 'Hi {name}, your Acme Store order {order} has been cancelled. If you paid online, the amount will be refunded. -Acme Store',
'refunded' => 'Hi {name}, the refund for your Acme Store order {order} has been processed to your original payment method. -Acme Store',
];
// HPOS (custom order tables): this file uses only WooCommerce's order methods.
add_action( 'before_woocommerce_init', function () {
if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
}
} );
// On a status change, queue the SMS so checkout and the admin screen never wait for it.
add_action( 'woocommerce_order_status_changed', function ( $order_id, $from, $to, $order ) {
if ( ! defined( 'OSS_SMS_API_KEY' ) || ! isset( OSS_SMS_STATUS_MAP[ $to ] ) || oss_sms_already_sent( $order, $to ) ) {
return;
}
as_enqueue_async_action( 'oss_sms_send', [ (int) $order_id, $to, 1 ], 'oss-sms', true );
}, 10, 4 );
add_action( 'oss_sms_send', 'oss_sms_send', 10, 3 );
function oss_sms_send( $order_id, $status, $attempt = 1 ) {
$order = wc_get_order( $order_id );
// Skip if the status changed again before this ran, or this status was already sent.
if ( ! $order || $order->get_status() !== $status || oss_sms_already_sent( $order, $status ) ) {
return;
}
$type = OSS_SMS_STATUS_MAP[ $status ];
if ( 'payment_received' === $type && 'cod' === $order->get_payment_method() ) {
$type = 'cod_confirmed';
}
$phone = oss_sms_indian_mobile( $order->get_billing_phone(), $order->get_billing_country() );
if ( ! $phone ) {
$order->add_order_note( "SMS \"$type\" not sent: the billing phone is not an Indian mobile number." );
return;
}
// Tracking link: the order's "tracking_url" custom field, or your courier plugin via the filter.
$url = (string) apply_filters( 'oss_sms_tracking_url', $order->get_meta( 'tracking_url' ), $order );
if ( '' === $url && false !== strpos( OSS_SMS_TEXTS[ $type ], '{url}' ) ) {
$order->add_order_note( "SMS \"$type\" not sent: add the tracking link in the tracking_url custom field." );
return;
}
$text = strtr( OSS_SMS_TEXTS[ $type ], [
'{name}' => oss_sms_plain( $order->get_billing_first_name(), 'Customer' ),
'{order}' => oss_sms_plain( $order->get_order_number(), (string) $order->get_id() ),
'{url}' => $url,
] );
$res = wp_remote_post( 'https://whitelabled.securesmsc.com/api/v2/sms/send', [
'timeout' => 15,
'headers' => [
'Authorization' => 'Bearer ' . OSS_SMS_API_KEY,
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
'body' => wp_json_encode( [
'sender_id' => OSS_SMS_SENDER_ID,
'recipient' => $phone,
'message' => $text,
] ),
] );
$code = is_wp_error( $res ) ? 0 : (int) wp_remote_retrieve_response_code( $res );
$body = is_wp_error( $res ) ? [] : (array) json_decode( wp_remote_retrieve_body( $res ), true );
if ( 200 === $code && ! empty( $body['success'] ) ) {
$sent = $order->get_meta( '_oss_sms_sent' );
$sent = is_array( $sent ) ? $sent : [];
$sent[ $status ] = $body['data']['message_id'];
$order->update_meta_data( '_oss_sms_sent', $sent ); // never send this status twice
$order->save();
$order->add_order_note( "SMS \"$type\" queued to $phone (message ID {$body['data']['message_id']})." );
return;
}
if ( is_wp_error( $res ) ) {
$why = $res->get_error_message();
} else {
// error_code first (e.g. TEMPLATE_MISMATCH), then error, then message
$why = "HTTP $code " . ( $body['error_code'] ?? $body['error'] ?? $body['message'] ?? 'error' );
$why .= isset( $body['message'] ) ? ": {$body['message']}" : '';
$errors = (array) ( $body['errors'] ?? [] ); // 422: per field; 400: a list
array_walk_recursive( $errors, function ( $e ) use ( &$why ) { $why .= " | $e"; } );
}
// Try again only when the API cannot have accepted the SMS: HTTP 429 (after Retry-After),
// 503, or a connection that never opened (cURL error 6 or 7). Never after a timeout.
$wait = 0;
if ( 429 === $code ) {
$wait = max( 60, (int) wp_remote_retrieve_header( $res, 'retry-after' ) );
} elseif ( 503 === $code || preg_match( '/^cURL error [67]:/', $why ) ) {
$wait = 120;
}
if ( $wait && $wait <= 900 && $attempt < 3 ) {
as_schedule_single_action( time() + $wait, 'oss_sms_send', [ (int) $order_id, $status, $attempt + 1 ], 'oss-sms' );
$why = rtrim( $why, '. ' ) . ". Trying again in $wait seconds.";
}
$order->add_order_note( "SMS \"$type\" to $phone not sent. $why" );
}
function oss_sms_already_sent( $order, $status ) {
$sent = $order->get_meta( '_oss_sms_sent' );
return is_array( $sent ) && isset( $sent[ $status ] );
}
// "+91 98765-43210", "098765 43210", "919876543210" -> "+919876543210"; anything else -> null
function oss_sms_indian_mobile( $phone, $country ) {
$d = preg_replace( '/\D/', '', (string) $phone );
if ( strlen( $d ) === 14 && 0 === strpos( $d, '0091' ) ) {
$d = substr( $d, 4 );
} elseif ( strlen( $d ) === 12 && 0 === strpos( $d, '91' ) ) {
$d = substr( $d, 2 );
} elseif ( strlen( $d ) === 11 && '0' === $d[0] ) {
$d = substr( $d, 1 );
} elseif ( $country && 'IN' !== $country ) {
return null; // a 10-digit number from another country
}
return preg_match( '/^[6-9]\d{9}$/', $d ) ? '+91' . $d : null;
}
// DLT {#alp#} variables take letters, digits and spaces, up to 40 characters.
function oss_sms_plain( $value, $fallback ) {
$v = trim( preg_replace( '/\s+/', ' ', preg_replace( '/[^A-Za-z0-9]/', ' ', (string) $value ) ) );
$v = rtrim( substr( $v, 0, 30 ) );
return '' !== $v ? $v : $fallback;
}The file uses only WooCommerce's order methods (wc_get_order, get_meta, update_meta_data, add_order_note), so it works with High-Performance Order Storage (HPOS) and with the older posts storage, and it declares HPOS compatibility. It needs PHP 7.4 or later. A send is retried only when the API cannot have accepted it: HTTP 429 (after the Retry-After wait, up to 15 minutes), HTTP 503, or a connection that never opened. After a timeout or a 500 the SMS may already be queued, so it is not sent again; check the delivery report instead.
Step 3: test with your own phone
Place a test order with your own mobile number as the billing phone, then change its status in WooCommerce → Orders. Each status you move it to should add an order note within a minute or so. These are notes the file produced in our tests:
SMS "payment_received" queued to +919876543210 (message ID 9002).
SMS "cod_confirmed" queued to +919876543211 (message ID 9003).
SMS "shipped" not sent: add the tracking link in the tracking_url custom field.
SMS "payment_received" not sent: the billing phone is not an Indian mobile number.
SMS "payment_received" to +919876543210 not sent. HTTP 401 Unauthorized: Invalid API key
SMS "refunded" to +919000000423 not sent. HTTP 400 SMS dispatch failed: Request validation failed | Template verification failed: Message does not match any approved template. No similar templates found. Message preview: 'Hi Test, the refund for your Acme Store order 4827...'
SMS "delivered" to +919000000429 not sent. HTTP 429 Rate limit exceeded: Too many requests. Please try again later. Trying again in 60 seconds.The 401 line came from the live API with a dummy key; the others came from a local copy of the API's responses. The texts in those notes are the ones to search for when something goes wrong; see the error table below.
Low-traffic stores: Action Scheduler runs its queue through WP-Cron, and WP-Cron runs only when someone visits the site. If your store gets few visits, or you have set DISABLE_WP_CRON, run the queue every minute from a real cron job. With WP-CLI installed:
# Low-traffic store: run the SMS queue every minute with WP-CLI (crontab -e)
* * * * * wp --path=/var/www/your-store action-scheduler run --group=oss-sms --quietThis matters for the transactional messages below, which must reach the customer within 30 minutes of the order or payment.
DLT templates ready to register
Every SMS must match a template approved on the DLT portal, with only the variables changed. Here are the eight texts the snippet uses, written with the Vi and BSNL variable tags: {#alp#} takes letters, digits and spaces up to 40 characters, and {#urg#} takes a web link. Replace "Acme Store" with your brand name, register them, and paste the same wording into OSS_SMS_TEXTS, with {name}, {order} and {url} in place of the tags.
| Message | Category | Template text to register | Variables |
|---|---|---|---|
| Order placed (awaiting payment) | Transactional | Hi {#alp#}, we have received your order {#alp#} at Acme Store. We will confirm it once the payment is received. -Acme Store | First name, order number |
| Payment received | Transactional | Hi {#alp#}, we have received the payment for your order {#alp#}. We will SMS you when it ships. -Acme Store | First name, order number |
| Cash on delivery confirmed | Transactional | Hi {#alp#}, your cash on delivery order {#alp#} at Acme Store is confirmed. Please pay when it is delivered. -Acme Store | First name, order number |
| Shipped, with tracking link | Service | Your Acme Store order {#alp#} has been shipped. Track it here: {#urg#} -Acme Store | Order number, tracking link (register the link) |
| Out for delivery | Service | Hi {#alp#}, your Acme Store order {#alp#} is out for delivery today. -Acme Store | First name, order number |
| Delivered | Service | Hi {#alp#}, your Acme Store order {#alp#} has been delivered. Thank you for shopping with us. -Acme Store | First name, order number |
| Cancelled | Service | Hi {#alp#}, your Acme Store order {#alp#} has been cancelled. If you paid online, the amount will be refunded. -Acme Store | First name, order number |
| Refunded | Service | Hi {#alp#}, the refund for your Acme Store order {#alp#} has been processed to your original payment method. -Acme Store | First name, order number |
These templates can't come "already approved". A DLT template belongs to the business that registers it: each store registers these texts on its own DLT entity, under its own header, and the operator approves them for that entity only. Nobody can hand you pre-approved templates for your brand. We help you file the entity, header and templates at no extra charge; the portal's one-time entity fee is about ₹5,900 including 18% GST (confirm on the portal), and approval usually takes 2–7 business days. See how DLT template approval works.
- Category. Order placed, payment received and COD confirmed respond to something the customer has just done, so they are Transactional, which TRAI ties to sending within 30 minutes. If you confirm bank transfers by hand hours later, register the payment message as Service too. Shipping, delivery, cancellation and refund updates are Service. Both reach numbers on DND.
- Tracking links. A
{#urg#}variable is checked against links you register (whitelist) with the template, so register your courier's or your own tracking URL pattern, or the shipped SMS will be blocked. - No amounts. The texts leave out order totals on purpose. A
{#num#}variable allows digits only, so "1,499.00" fails the check, and a ₹ sign turns the SMS into Unicode, which holds 70 characters instead of 160. - Check before you send. Paste a filled-in message and its template into the DLT template checker. More on tags in DLT template variables.
Change statuses, texts and tracking links
- Fewer messages: delete lines from
OSS_SMS_STATUS_MAP, for example to send only payment received, shipped and delivered. - Custom statuses: add the status slug (without
wc-) with one of the message types, and a text for any new type inOSS_SMS_TEXTS. - Tracking link: by default it comes from an order custom field named
tracking_url, which staff can add in the order's Custom Fields box before marking the order shipped. If a courier plugin stores the link, read it through theoss_sms_tracking_urlfilter:
// Optional, at the end of oss-order-sms.php: take the link from your courier plugin's
// order field. "_courier_tracking_link" is an example: use the meta key your plugin saves.
add_filter( 'oss_sms_tracking_url', function ( $url, $order ) {
return $url ?: (string) $order->get_meta( '_courier_tracking_link' );
}, 10, 2 );Keep the code and the registered template in step: if you change a word in one, change it in the other, or the operator will block the message.
Order notes and how to fix them
| Order note says | Cause | Fix |
|---|---|---|
| queued to +91… (message ID …) | The API accepted the SMS. | Nothing. Delivery shows in your dashboard's reports. |
| the billing phone is not an Indian mobile number | The number isn't 10 digits starting 6–9 (with or without +91 or 0), or it's a 10-digit number with a non-Indian billing country. | Correct the phone on the order, or make the phone field required at checkout. |
| add the tracking link in the tracking_url custom field | The shipped text has {url} but the order has no link. | Add the link, then set the status again, or use the filter. |
| HTTP 401 Unauthorized | Wrong, disabled or expired key, or an inactive account. | Check OSS_SMS_API_KEY in wp-config.php. |
| HTTP 403 Forbidden: IP address not allowed | The store's server IP isn't on the key's allowed list. | Add it under API Management → IP Whitelisting. |
| HTTP 400 Invalid sender ID | OSS_SMS_SENDER_ID isn't an approved header on your account. | Use the 6-character header exactly as approved, without -S or -T. |
| HTTP 400 SMS dispatch failed … Template verification failed | The text doesn't match an approved template. | Compare it with the template word for word; fix OSS_SMS_TEXTS. |
| HTTP 400 … Insufficient credits | Balance too low. | Top up, then set the status again. |
| HTTP 422 Validation failed | A field is missing or wrong, such as an empty sender ID. | Check the two constants and the text length (1,600 characters at most). |
| HTTP 429 Rate limit exceeded … Trying again | More than the key's limit: 60 requests a minute or 10,000 a day by default. | Nothing for the per-minute limit; the file retries. A daily limit is not retried. |
| cURL error 28 (timeout) or HTTP 500 | No clear answer from the API; the SMS may still have gone. | Check the dashboard's reports before sending by hand. |
Get a free API key + 100 test SMS. Generate your key now and test the snippet on a staging copy of your store; verified businesses get 100 free test SMS once KYC and DLT mapping are done.
Prefer a plugin? One third-party option
If you'd rather set things up in the admin than upload a file, one plugin on wordpress.org says it can connect to any SMS API. We checked its listing on 7 November 2026; we have not tested it with our API, it isn't ours, and we can't support it.
- WSMS (formerly WP SMS) by VeronaLabs, version 7.2.12, 7,000+ active installations at the time we checked.
- Its free version includes a Custom Gateway that, according to the listing, connects any SMS API, with custom HTTP headers, parameters and a raw JSON body. That is what our API needs: a POST to
https://whitelabled.securesmsc.com/api/v2/sms/sendwith anAuthorization: Bearerheader and a JSON body withsender_id,recipientandmessage. - WooCommerce order-status SMS is not in the free version: the listing puts it in their paid All-in-One package.
Whichever route you choose, the DLT rules are the same: your header and every template must be approved on your own DLT entity first.
What order SMS cost
One rate covers every message type: ₹0.20 per SMS on Starter (up to 10,000 SMS a month) and ₹0.15 on Business (up to 1,00,000 a month), plus 18% GST. You pay per delivered message, with no setup fee, no monthly fee and no minimum top-up, and credits never expire.
Worked example at list prices, not a case study: a store with 1,500 orders a month that sends three SMS per order (payment received, shipped, delivered) sends 4,500 SMS. On Starter that is 4,500 × ₹0.20 = ₹900, plus ₹162 GST = ₹1,062 a month. See pricing for plan details. For OTP at login or checkout, see the OTP SMS guide; for plain PHP outside WordPress, the PHP SMS guide.