=== Sendly SMS for WooCommerce ===
Contributors: tomlwbioda
Donate link: https://buycoffee.to/tomaleb
Tags: woocommerce, sms, order status, notifications, sendly
Requires at least: 6.2
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.0.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

SMS notifications for WooCommerce via the Sendly gateway on order status change. Per-status templates and an alphanumeric sender ID.

== Description ==

Sendly sends a text message to the customer whenever a WooCommerce order changes status — for example when payment is received (Processing), the order is shipped (Completed), or it is cancelled. Messages are delivered through the **Sendly** SMS gateway and can be shown with an alphanumeric sender ID ("nadpis", e.g. your shop name) instead of a phone number.

**Key features**

* Per-status on/off switch and editable message template (works with custom order statuses too).
* Placeholders: `{shop_name}`, `{order_number}`, `{order_total}`, `{currency}`, `{customer_first_name}`, `{customer_last_name}`, `{order_status}`, optional `{tracking_number?}`.
* Asynchronous sending via Action Scheduler — checkout is never blocked by the SMS call.
* Automatic retries with exponential backoff and per-order idempotency (no duplicate texts).
* International-ready phone normalisation based on the order's billing country.
* Live SMS segment/encoding counter (GSM-7 vs UCS-2) so you can see cost while editing templates.
* "Send test SMS" button in the settings.
* Optional delivery receipts (DLR webhook) that record DELIVERED/ERROR on the order.
* Optional RODO/GDPR consent (opt-out) checkbox at checkout.
* Create a Sendly account straight from the plugin (100 free SMS to start) — no separate signup needed.
* Quick links to the Sendly customer panel.
* Per-order audit as order notes, plus a "sendly" channel in WooCommerce → Status → Logs. Configurable retention; phone numbers are masked and message bodies are not stored by default.
* HPOS (High-Performance Order Storage) compatible.

**Sender ID (nadpis)**

The Sendly API field `from` accepts a numeric virtual number only. The alphanumeric sender ID is configured on the Sendly side and bound to that number. The plugin provides a sender-ID field and a forward-compatible hook (`sendly_request_body`) so it can be sent in the API payload once Sendly exposes that option.

== External services ==

This plugin relies on two external services. You need a Sendly account and API token to use it.

**1. Sendly SMS gateway** — used to deliver every SMS.

* Endpoint: `https://api.sendly.link/api/sms`
* Data sent: the destination mobile phone number, the rendered message text (which may include the order number, order total, the customer's first/last name and — when you enable "order notes as SMS" — the note text you write), and your Sendly sender number and API token (for authentication).
* When: on enabled order status transitions, when you add a manual order note (if that option is enabled), and on manual "Send test SMS". Delivery receipts are received (Sendly posts to your site); your site makes no outbound status-query call.
* Provider: Sendly (Syntell S.A.). Website: https://sendly.link/
* Terms of Service: https://sendly.link/pl/regulamin/ — Privacy Policy: https://sendly.link/pl/polityka-prywatnosci/

**2. Sendly registration page (sendly.link)** — used only if you choose to create an account from inside the plugin.

* Page: `https://sendly.link/pl/rejestracja/`
* Data sent: when you click "Create account", the details you typed (name, e-mail, company name, tax ID, address, phone, and the shop name shown as the SMS sender) are posted to your own site (admin-ajax) so it can store your e-mail and shop name and build the link; your browser is then redirected to the page above with those details pre-filled via the URL fragment. The plugin does not forward this data to any third-party server — your browser carries it to sendly.link, and the fragment does not reach server logs. You set the password and complete a bot-check on sendly.link, then return to your site. The password never touches your WordPress site.
* When: only when you submit the in-plugin signup form.
* Provider: Sendly (Syntell S.A.). Terms: https://sendly.link/pl/regulamin/ — Privacy Policy: https://sendly.link/pl/polityka-prywatnosci/

Make sure you have a lawful basis and, where required, a data-processing agreement with the provider.

== Installation ==

1. Upload the `sendly` folder to `/wp-content/plugins/`, or install the ZIP via Plugins → Add New → Upload.
2. Activate the plugin. WooCommerce must be active.
3. Go to WooCommerce → Settings → SMS.
4. Enter your Sendly API token; the sender number (from) is optional.
5. Enable the order statuses you want and adjust the message templates.
6. Use "Send test SMS" to verify your configuration.

== Frequently Asked Questions ==

= Do I need a Sendly account? =
Yes. You need a Sendly SMS account, a virtual number and an API token. The plugin makes this easy: go to WooCommerce → Settings → SMS → Sign up for Sendly, fill in your details and click "Create account" — you finish on sendly.link (password + bot check) and get 100 free SMS to start. Alternatively register directly at https://sendly.link/pl/rejestracja/ .

= Why is my sender shown as a number instead of my shop name? =
The alphanumeric sender ID ("nadpis") is registered and bound to your number on Sendly's side. The plugin's API call sends only the numeric `from`; the provider substitutes the approved sender ID.

= Does it work with the block-based checkout? =
The opt-out consent checkbox uses the classic checkout hooks. Order-status SMS sending works regardless of the checkout type.

= Will it slow down checkout? =
No. Sending happens in the background through Action Scheduler.

= How are delivery receipts (DLR) secured? =
The DLR endpoint is guarded by a random shared secret. The settings page shows a ready-to-use URL with the secret in the query string for convenience; you can instead send the secret in an `X-Sendly-Secret` HTTP header to keep it out of access logs. The secret can be regenerated from the settings page at any time (the old URL then stops working).

= Can I send to international numbers? =
Phone numbers are normalised using the order's billing country. Actual delivery depends on what the Sendly gateway supports; numbers outside the gateway's accepted length are skipped and logged.

== Screenshots ==

1. The Sendly SMS settings — visible API token, sender number and ID, options, and per-status message templates with the live UCS-2/GSM-7 segment counter.
2. An order note recording the delivered SMS and its Sendly message ID.

== Changelog ==

= 1.0.1 =
* Use boolean autoload values in add_option()/update_option() for WordPress 6.7+ compatibility.

= 1.0.0 =
* Initial release: per-status SMS via Sendly, async sending with retries, phone normalisation, encoding/segment counter, test-SMS button, delivery receipts, RODO opt-out, activity log and HPOS support.

== Upgrade Notice ==

= 1.0.1 =
Compatibility update; no functional changes.
