=== BulkSMSBD for WooCommerce ===
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 7.4
Tags: woocommerce, sms, otp, order notifications, bangladesh
Stable tag: 1.0.20
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Send order status SMS to the billing phone and require SMS OTP verification before checkout.

== Description ==

Send WooCommerce order updates and verify checkout billing phone numbers using the BulkSMSBD SMS gateway. The plugin requires WooCommerce 9.0 or later, a BulkSMSBD account, an API key, and an approved Sender ID. BulkSMSBD service charges apply.

* Send or queue customer order-status notifications with editable Bangla or English templates.
* Enable optional SMS OTP at checkout.
* Send manual SMS, view the account balance, and review or export submission history.

== Installation ==

1. Install and activate WooCommerce, then install and activate BulkSMSBD for WooCommerce from the WordPress Plugins screen.
2. Open BulkSMSBD > Settings in the WordPress sidebar.
3. Enter your BulkSMSBD API key and approved Sender ID. If your BulkSMSBD account requires an IP whitelist, add the web server's outbound IP in BulkSMSBD.
4. Enable Order status notification and select which statuses should send an SMS. Processing, Completed and Cancelled are the initial selections. Edit the default message or override it for individual statuses.
5. Enable Checkout OTP and save. In a Checkout Block, enable the phone field under Address Fields. With a shortcode checkout, make sure the checkout template shows the billing phone field.
6. Place a test order using a Bangladeshi mobile number you control. Verify that checkout rejects an unverified number, accepts a valid OTP, and rejects a different billing phone. Change the test order to a selected status and verify the SMS and its order note.

== Operation ==

* Supports Bangladeshi mobile numbers in local (01XXXXXXXXX), international (+8801XXXXXXXXX) or API (8801XXXXXXXXX) format.
* OTP verification covers guest and signed-in shoppers in the standard classic and block checkout flows. It applies to all payment methods. Orders entered in the admin and imported orders do not go through checkout OTP. Test third-party express checkout buttons separately.
* The six-digit code is valid for 5 minutes with up to 5 attempts. Successful verification is tied to the billing number and checkout session for 15 minutes, so shoppers can retry checkout if another field or payment fails.
* Requests are rate-limited. Keep checkout and WooCommerce AJAX requests out of page caches. When using a reverse proxy, configure the server to populate REMOTE_ADDR with the trusted client address.
* Order status SMS sends immediately by default. Select queued sending in BulkSMSBD settings to use WooCommerce Scheduled Actions. Keep WordPress cron running for queued sending. Check WooCommerce > Status > Scheduled Actions for the bulksmsbd-woocommerce group and open the order notes for submission results. BulkSMSBD code 202 means the gateway accepted the SMS for submission. Delivery confirmation is separate.
* Customize messages in Bangla or English. If your Sender ID requires Bangla SMS, set Bangla templates before enabling the features.
* The API key stays server-side. You can set BULKSMSBD_WC_API_KEY in wp-config.php to keep the key outside the WordPress settings database. A blank key in settings keeps the previously saved value. To rotate it, enter a new key or update the constant.
* OTP data is stored as keyed digests in the plugin's state table and cleaned up hourly. The gateway receives the normalized destination phone and SMS body over HTTPS.

== Send SMS and SMS Log ==

* Send SMS shows the current BulkSMSBD balance for the configured API key. Select Refresh balance to fetch it again.

* Go to BulkSMSBD > Send SMS in the WordPress sidebar. Paste up to 100 unique Bangladeshi mobile numbers and enter a Bangla or English message. The form shows live character and part counts per recipient. Duplicate numbers are removed before submission. The form starts with the saved Sender ID. You can enter another approved Sender ID for that submission.
* BulkSMSBD > SMS Log shows submission time, recipient, source, order ID when applicable, result and details, including the gateway response code and API response ID when returned. Filter by source or result.
* The log records new manual, order-status, OTP and test submissions after installation or upgrade. It keeps entries for 30 days. SMS bodies are shown for new non-OTP entries. Checkout OTP bodies are excluded and OTP recipients are masked. Older entries have no stored body.
* Access requires the WooCommerce management capability. Accepted is a gateway submission result. See the BulkSMSBD delivery report for handset delivery.

== Phone settings ==

* Use the existing WooCommerce billing phone for customer notifications.
* Keep WooCommerce defaults, make the billing phone required, or allow it to be optional. Checkout OTP always requires a valid number.
* Add an optional placeholder to show shoppers the expected format.
* Save the admin phone, API key, and Sender ID, then click Send Test SMS. The admin phone is used for this manual test.
* If you see API error 1032, add the WordPress server's outbound IP to the BulkSMSBD API whitelist.

== WooCommerce notifications ==

Enable the order-page SMS shortcut, admin new-order, product publication and low-stock alerts, or customer order confirmation in the BulkSMSBD integration settings. The order shortcut opens the composer with the saved billing phone. Admin alerts use the configured admin phone. Customer order confirmation can be sent before payment. Checkout SMS confirmation controls automatic customer order messages and is separate from OTP. Per-status templates can be toggled independently of status notifications.

== Templates ==

Order updates: %first_name%, %order_number%, %amount%, %status%, %store_name%, %currency%.
%amount% is the WooCommerce order total with the store's decimal precision and no currency symbol. Use %currency% for the order currency code (such as BDT).
Existing templates can still use {store_name}, {order_number}, {status} and {customer_name}.

Example order update:
Dear %first_name%, your order #%order_number% totals %amount% taka.
OTP: {store_name}, {otp}. The {otp} placeholder is required.

Example order update:
{store_name}: আপনার অর্ডার #{order_number} এর স্ট্যাটাস: {status}।

Example OTP:
{store_name}: আপনার অর্ডারের যাচাই কোড {otp}। কোডটি ৫ মিনিট পর্যন্ত কার্যকর।

== External service ==

BulkSMSBD provides SMS delivery for this plugin. It requires a BulkSMSBD account and an API key configured by the store administrator.

* https://bulksmsbd.net/api/smsapi receives the API key, Sender ID, recipient phone numbers and message text when an SMS is submitted. Message text can include checkout OTPs or order details based on the enabled features and templates.
* https://bulksmsbd.net/api/getBalanceApi receives the API key when an authorized user opens or refreshes the Send SMS page to retrieve the account balance.

See the [BulkSMSBD API documentation](https://bulksmsbd.com/bulksms-api-bangladesh.php) and [BulkSMSBD customer portal](https://bulksmsbd.net/).

== Changelog ==

= 1.0.20 =
* Resolved reported Plugin Check errors, updated the directory slug, and prepared custom database queries for review.
