=== Moolre SMS Notifications for WooCommerce ===
Contributors: moolre
Tags: Moolre, SMS, Notifications, WooCommerce, Ghana SMS
Requires at least: 6.2
Tested up to: 7.0
Stable tag: 1.2.1
Requires PHP: 7.4
Requires Plugins: woocommerce
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Send automated WooCommerce order SMS alerts via Moolre's reliable SMS gateway.

== Description ==

Moolre SMS Notifications plugin allows your WooCommerce store to automatically send SMS messages to customers with comprehensive tracking and management features.

**Main Features:**
- **Dashboard**: View SMS statistics, recent activity, and credit balance
- **Bulk SMS**: Send messages to multiple customers at once
- **SMS Credits**: Track your credit usage and balance
- **Settings**: Configure API, templates, and notification triggers

= Version 1.2.1 Updates =

* Order SMS can use the linked customer's phone when the order has no billing phone
* Private order notes show gateway acceptance or the reason an SMS failed
* Fixed Sandbox sends without a merchant Sender ID, on-hold templates, and default order messages
* New Live / Sandbox environment switch under Settings > API Settings
* Dashboard and SMS Credits pages show stats for Live or Sandbox separately
* Fixed SMS balance lookup and failed-send detection

= Version 1.2.0 Updates =

* Fixed all "MSWP SMS" references to "Moolre SMS"
* Improved admin interface organization
* Added proper escaping for all admin URLs
* Enhanced security for all database queries
* Fixed timezone handling in date functions
* Improved input validation and sanitization

= Why Choose Moolre SMS? =

* Reliable delivery to all Ghanaian networks
* Competitive pricing with transparent rates
* Instant delivery with high throughput
* Dedicated sender IDs for brand recognition
* Detailed delivery reports and analytics

= Plugin Features =

**Dashboard Features:**
- Real-time SMS statistics
- Credit balance overview
- Recent SMS activity log
- Visual charts for usage patterns

**Bulk SMS Features:**
- Select multiple recipients
- Message character counter
- Placeholder support
- Send history tracking

**Credit Management:**
- Balance tracking
- Usage history
- Transaction records
- Credit alerts

**Settings Configuration:**
- API Key setup
- Sender ID configuration
- Order status triggers
- Customizable message templates:
  - Order processing
  - Order completed
  - Order refunded
  - Order pending
  - Order on hold
  - Order cancelled
  - Customer registration

== Installation ==

1. Go to **WordPress Admin** → **Plugins** → **Add New**
2. Search for "Moolre SMS Notifications for WooCommerce"
3. Click **Install Now** and then **Activate**

= Setup Instructions =

1. Navigate to **Moolre SMS** in your WordPress admin menu
2. Configure your settings through the four main tabs:

**Dashboard Tab**
- Monitor your SMS activity and credit balance

**Bulk SMS Tab**
- Select recipients from your customer list
- Compose and send bulk messages

**SMS Credits Tab**
- View your current balance
- Check usage history
- Monitor transaction records

**Settings Tab**
- **API Configuration**:
  - Choose the environment: Live or Sandbox
  - Enter your Moolre API key
  - Set your sender ID
  - Configure initial credits

- **Features**:
  - Enable/disable registration notifications
  - Select which order statuses trigger SMS

- **Message Templates**:
  - Customize messages for each order status
  - Set registration welcome message
  - Use dynamic placeholders

3. Click **Save Settings** to apply your configuration

== Changelog ==

= 1.2.1 =
* Fix: Order notifications fall back to the linked customer's billing or registration phone when the order phone is empty
* Fix: Missing phone numbers and API settings are recorded as failed SMS instead of being silently skipped
* Feature: Private order notes record gateway acceptance or the failure reason and error code for every enabled status change
* Fix: Sandbox uses its system Sender ID when no merchant Sender ID is configured; Live still requires an approved Sender ID
* Fix: On-hold notifications use the saved on_hold template
* Fix: Default order messages fill in the order number and status correctly
* Fix: Rapid order status changes receive unique SMS references
* Fix: Gateway rejections with an empty error code are no longer logged as sent
* Feature: Live / Sandbox environment switch (Settings > API Settings). The same API key works in both.
* Feature: SMS logs record the environment they were sent from; Dashboard and SMS Credits pages can show Live or Sandbox stats
* Feature: Sandbox reminder on the WooCommerce Orders screen
* Fix: Balance is now read from the SMS Account Status endpoint (/open/sms/status)
* Fix: Messages rejected by Moolre are logged as failed with the Moolre error code
* Fix: Balance loads in the background instead of delaying page load
* Fix: Charts start at zero and the Chart.js file name was corrected
* Security: Escaped SMS content in the admin activity tables

= 1.2.0 =
* Branding: Updated all references from "MSWP SMS" to "Moolre SMS"
* UI: Reorganized admin tabs (Dashboard, Bulk SMS, SMS Credits, Settings)
* Security: Fixed SQL injection vulnerabilities
* Security: Added input validation for all forms
* Performance: Optimized database queries
* Fix: Corrected timezone handling in date functions

= 1.1.0 =
* Added Bulk SMS functionality
* Implemented credit tracking system
* Enhanced dashboard interface
* Added transaction history

= 1.0.0 =
* Initial release with basic SMS notification features

== Frequently Asked Questions ==

= How do I get my Moolre API credentials? =
Visit [Moolre's developer portal](https://app.moolre.com/developers) to generate your API key after creating an account.

= Can I customize the sender ID? =
Yes, you can set your preferred sender ID in the Settings tab under API Configuration. Note that sender IDs must be pre-approved.

= What happens if I run out of SMS credits? =
The plugin will stop sending notifications until you top up your Moolre account. You'll see low balance warnings in your dashboard.

= What is Sandbox mode? =
Sandbox lets you test without spending paid credits. Sandbox SMS are still delivered for real, but they are sent with Moolre's system Sender ID instead of yours, and you get 100 free Sandbox credits. Switch environments under Settings > API Settings. Remember to switch back to Live before going into production, because order notifications to customers are also sent through Sandbox while it is on.

= How can I track my SMS delivery? =
The Dashboard shows gateway submission results in Recent Activity. For order notifications, private order notes also show whether Moolre accepted the SMS or why it failed. A "sent" result means the gateway accepted the request; it does not confirm delivery to the handset.

= Why is no SMS sent when I update an order? =
SMS are triggered when the order actually moves to an enabled status. Clicking Update while keeping the same status does not send another SMS. The order needs a billing phone, or a linked customer with a billing or registration phone. Guest orders need their own billing phone. Check the private order notes and Moolre SMS Dashboard > Recent Activity for missing settings, insufficient credits, API errors, or other failures. Sandbox still needs a valid API key and available Sandbox credits.

== Support ==
For technical support or feature requests, please contact:
- Email: bright@moolre.com
- Website: [https://moolre.com](https://moolre.com)
- Developer Portal: [https://docs.moolre.com](https://docs.moolre.com)

== Screenshots ==
1. Dashboard overview with statistics
2. Bulk SMS composition interface
3. SMS credit management view
4. API configuration settings
5. Message template customization
6. Order status trigger selection
