=== Msg91 for WooCommerce ===
Contributors: prashantpatidar
Tags: woocommerce, sms, msg91, notifications
Requires at least: 5.0
Tested up to: 6.8
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Easily send automated SMS notifications via MSG91 for WooCommerce events.

== Description ==
The **Msg91 for WooCommerce** plugin enables automated SMS notifications via MSG91 when specific WooCommerce events occur. This plugin provides an admin interface for managing webhook automations and settings, including storing and retrieving the MSG91 AuthKey.

## Features
- **Automated SMS Notifications** for WooCommerce events.
- **Admin Interface** to manage automation triggers.
- **AuthKey Management** stored securely in the database.
- **Scalable Architecture** for easy extension.

## Installation
1. Download the plugin ZIP file.
2. Navigate to **Plugins > Add New** in your WordPress admin panel.
3. Click **Upload Plugin**, select the ZIP file, and click **Install Now**.
4. Activate the plugin.
5. Go to **WooCommerce > MSG91 Settings** to configure the plugin.

## Supported WooCommerce Events
This plugin triggers SMS notifications for:
- New Customer Registration (`woocommerce_new_customer`)
- Customer Update (`woocommerce_update_customer`)
- New Order Placement (`woocommerce_new_order`)
- Order Update (`woocommerce_update_order`)
- Payment Completion (`woocommerce_payment_complete`)
- Order Completion (`woocommerce_order_status_completed`)
- Order Cancellation (`woocommerce_order_status_cancelled`)
- Order Refund (`woocommerce_order_status_refunded`)

## How to Use
### Setting Up the MSG91 AuthKey
1. Navigate to **WooCommerce > MSG91 Settings**.
2. Enter your **AuthKey**.
3. Click **Save** to store it securely in the database.

### Managing Automation Rules
1. Navigate to **WooCommerce > MSG91 Automation**.
2. Add or update automation rules for triggering Campaign notifications via multiple channels.

## File Storage and Data Management
This plugin follows WordPress.org guidelines for file storage:

### Data Storage Location
- **Plugin Data**: All plugin-generated files are stored in the WordPress uploads directory at `wp-content/uploads/Msg91-WooCommerce/`
- **WordPress Compliance**: This approach ensures compatibility with WordPress.org plugin guidelines and prevents issues with plugin updates
- **Automatic Cleanup**: Files are automatically removed when the plugin is uninstalled

### File Operations
The plugin provides secure file operations using WordPress filesystem API:
- **Saving Files**: `msg91_woocommerce_save_json_file($filename, $data)` - Saves JSON data to uploads directory
- **Reading Files**: `msg91_woocommerce_read_json_file($filename)` - Reads JSON data from uploads directory
- **Deleting Files**: `msg91_woocommerce_delete_json_file($filename)` - Deletes files from uploads directory
- **Migration**: Automatic migration of existing files from plugin directory to uploads directory during activation

## External Services
This plugin connects to external services to provide SMS functionality:

### MSG91.com
- **Purpose**: SMS delivery service for sending automated notifications
- **What data is sent**: User phone numbers, message content, and campaign data
- **API Endpoint**: https://control.msg91.com/api/v5
- **Terms of use**: https://msg91.com/terms
- **Privacy policy**: https://msg91.com/privacy

### Additional Services
- **IP Info API**: Used for location-based services (https://ipinfo.io/json)
- **Sokt.io**: Used for flow management (https://flow.sokt.io)

## Support
For any issues, contact support via [GitHub Issues](https://github.com/your-repo/issues) or WooCommerce Support Forums.

== License ==
This plugin is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This plugin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this plugin; if not, see https://www.gnu.org/licenses/gpl-2.0.html.

## License
This plugin is licensed under the [GPLv2 or later](https://www.gnu.org/licenses/gpl-2.0.html).
