Skip to content

Developer notes

Hook Purpose
place_order New order message (not for save, an admin editing an order).
change_order_status_post Status message; skipped for the first status of a new order.
create_shipment_post Shipment message.
update_shipment_post (4.18+) New tracking number on an existing shipment. Does not exist in 4.17, where only new shipments send.
update_profile Welcome message for accounts created on the storefront.
update_product_amount Low stock message (core low stock threshold).

Handlers only write rows to the queue; they never call Twilio and catch every error, so an SMS problem can never block an order status change. Messages are sent by index.php?dispatch=kv_sms_notifications.run&key=<cron key>.

Table Content
kv_smsn_messages Queue and log (state, body, language, encoding, parts, Twilio SID, error, price, attempts, dedupe key).
kv_smsn_message_log History of each message (queued, sent, receipts, retries).
kv_smsn_texts Your texts per company, event, order status, recipient and language.
kv_smsn_rules On/off switches per company, event, order status and recipient.
kv_smsn_credentials Twilio account; the Auth Token is encrypted (AES-256-CBC + HMAC) with a key derived from crypt_key.

The dedupe key makes a replayed event (double click, the same status change within a minute, a retried request) produce one message.

  • kv_sms_notifications.receipt (storefront, POST): Twilio status callback. Checked with X-Twilio-Signature; a late “sent” never overwrites “delivered”.
  • kv_sms_notifications.run (storefront, GET): cron. Sends due messages, asks Twilio about messages without a receipt after 30 minutes, prunes the log. Answers sent=.. failed=.. retry=.. waiting=.. checked=...

Both are trusted controllers (no form key) and answer with Cache-Control: no-store and X-Robots-Tag: noindex. The add-on prints nothing on storefront pages, so full page cache is not affected.

Tygh\Addons\KvSmsNotifications\Text\Segmenter implements GSM 03.38 (basic + extension table, 160/153) and UCS-2 (70/67, UTF-16 units, so an emoji counts 2). The admin script uses the same tables, sent from PHP.

On a development store (every storefront host localhost, *.local or *.test) you can point the API at a local mock in local_conf.php:

define('KV_SMS_NOTIFICATIONS_API_BASE', 'http://127.0.0.1:18750/2010-04-01');

It is ignored on any other host.

The add-on ships Upgrade\Synchronizer: after files are replaced in place, the next admin page adds missing tables, columns, settings and language variables without touching your data.