=== SendPK SMS for WooCommerce ===
Contributors: sendpk
Tags: sms, woocommerce, order notifications, otp, pakistan
Requires at least: 5.8
Tested up to: 6.8
Requires PHP: 7.2
Stable tag: 2.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Automatic order-status SMS (approved template or free text) plus SMS OTP phone verification, powered by your SendPK account.

== Description ==

SendPK SMS for WooCommerce texts your customer — from your own approved
Sender ID — every time their order reaches a status you choose:

* Order Received / New Order
* Pending, Processing, On Hold
* Completed / Delivered
* Cancelled, Refunded, Failed

**Two message types, per status.** Each status block picks its own type:

* FIXED — an APPROVED SendPK template. A flexible key/value builder
  produces ANY JSON the template needs; nothing is hard-coded. Rows like
  "name → Customer first name" and "order-id → Order ID" send
  {"name":"Umair","order-id":"456723"}.
* DYNAMIC — free text you write yourself, with placeholders swapped for
  real order values: %customer_name%, %order_id%, %order_total%,
  %shop_name% and more. Optional Unicode mode for Urdu text.

**OTP phone verification.** Verify customer phones with a one-time SMS
code on the My Account signup form and/or the checkout page. Configurable
code length (4/6), expiry, max attempts and resend wait; codes are stored
server-side (hashed) and all checks run on the server.

**SMS Logs.** Every send — order SMS, OTP SMS and tests, success or
failure — is recorded with the exact message, the raw API reply and a
parsed Success/Failed status (OK ID:12345 = accepted; error codes 1/4/5/
6/7/8/9 are translated to readable reasons). Filter by status and date,
search by phone or order id, export CSV. Auto-cleanup after a
configurable number of days (default 30). Note: "Success" means SendPK
ACCEPTED the message — check your SendPK delivery report for final
handset delivery.

Other features:

* Automatic phone fixing — 0300… becomes 92300… (country code configurable)
* Send Test SMS box (Fixed or Dynamic) — reply shown on screen and logged
* One SMS per order per status — guarded against duplicate hook firing
* Safe without WooCommerce: shows a notice, never a fatal error
* HPOS (High-Performance Order Storage) compatible

You need a SendPK account (https://sendpk.com) with an API key, an
approved Sender ID / mask and — for Fixed mode — approved template ids.
The API key is the only login used; username/password auth is deprecated.

== Installation ==

1. In WordPress go to Plugins → Add New → Upload Plugin.
2. Choose sendpk-sms-woo.zip, click Install Now, then Activate.
3. Go to WooCommerce → SendPK SMS.
4. Enter your API Key, Sender ID and country code (default 92); turn on
   Unicode if you send Urdu. Save.
5. Open a status block (e.g. Order Received), enable it, pick Fixed or
   Dynamic, and fill in the template id + rows OR the message text. Save.
6. (Optional) Open OTP Verification and enable it for signup/checkout.
7. Use the Send Test SMS box to confirm everything works, then check the
   SMS Logs tab.

== Frequently Asked Questions ==

= No SMS arrives — what do I check first? =
API key, Sender ID, and (Fixed mode) that the template id is APPROVED.
Then open the SMS Logs tab — every attempt is there with the raw API
reply and the reason it failed.

= What do the API error numbers mean? =
1 wrong login/api_key, 4 empty sender, 5 empty number, 6 empty message,
7 invalid number, 8 out of credit, 9 rejected.

= What phone format does the customer need? =
Any common local format works. The plugin strips spaces, +, dashes and
brackets, and converts a leading 0 to your country code (0300… → 92300…).

= Does "Success" mean the SMS was delivered? =
No — it means SendPK accepted it (OK ID:…). For final handset delivery,
check the delivery report in your SendPK account.

= Is the OTP code stored or logged anywhere? =
Only a hash of the code is stored server-side, and log entries mask the
code (******). It is never shown or echoed in readable form.

== Changelog ==

= 2.0.0 =
* Dynamic (free text) message type with %placeholders%, per status
* Unicode option (type=unicode) for Urdu / non-English dynamic messages
* OTP phone verification on signup and checkout
* SMS Logs: database table, Success/Failed parsing (OK ID / error codes),
  filters, search, pagination, CSV export, retention auto-cleanup
* Test box supports both message types; test results are logged

= 1.0.0 =
* First release.
