=== Mira – AI Shopping Companion ===
Contributors: mira
Tags: woocommerce, chat, chatbot, ai, shopping-assistant
Requires at least: 6.0
Tested up to: 6.8
Requires PHP: 8.1
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Add the Mira AI shopping companion to your WooCommerce store and let shoppers get instant product help.

== Description ==

Mira is an AI shopping companion for e-commerce stores. This plugin:

* Injects the Mira widget into your storefront using the official embed snippet (tenant ID + API URL globals followed by the async widget script).
* Provides a `[mira_chat]` shortcode for placing the widget on a specific page.
* Shows a small "Ask Mira" fallback link to browsers with JavaScript disabled.
* Sends anonymised `add_to_cart` and `order_created` events to your Mira tenant using a server-side API key.
* Exposes `mira/v1/products` and `mira/v1/status` REST endpoints for catalog syncing and health checks (administrators only).
* Stores an anonymous session identifier in the WooCommerce session so conversations can be tied to carts.

No customer names, email addresses, billing/shipping addresses, IP addresses, or payment details are ever transmitted. Only catalog data, quantities, order totals and a random session UUID are sent.

== Installation ==

1. Upload the `mira-ai-shopping-companion` folder to `/wp-content/plugins/` (or install the ZIP via Plugins → Add New).
2. Activate the plugin through the Plugins screen.
3. Go to Settings → Mira.
4. Enter your **Tenant ID** (from the Mira dashboard), the **API URL** (default `https://api.mira.app`) and your server-side **API key**.
5. Adjust the widget appearance options and save.
6. Visit the storefront to confirm the assistant appears. WooCommerce is recommended but not required for the widget.

== Frequently Asked Questions ==

= Do I need WooCommerce? =

No. The widget, shortcode, settings page and status endpoint work without WooCommerce. Product syncing and cart/order events require an active WooCommerce installation.

= Where do I find my Tenant ID and API key? =

Sign in to your Mira dashboard and open Settings → Store connections. Copy the Tenant ID and generate a server-side API key there.

= How do I show Mira only on one page? =

Turn off "Widget enabled" in Settings → Mira and add the `[mira_chat]` shortcode to the desired page.

= Is the API key sent to the browser? =

No. The key is used only by server-side `wp_remote_post` calls and is never included in the inline widget configuration.

= Can I embed the widget manually? =

Yes. Add this to your theme footer:

`<script>window.MIRA_TENANT_ID="YOUR_TENANT_ID";window.MIRA_API_URL="https://api.mira.app";</script><script async src="https://api.mira.app/mira-widget.js"></script>`

= How do I sync products? =

Authenticate as a WordPress administrator (cookie nonce or application password) and call `/wp-json/mira/v1/products?per_page=50&page=1`. Mira can also push catalog events directly via the integration API.

== Security notes ==

* The REST endpoints require the `manage_options` capability. If a nonce header (`X-WP-Nonce`) is supplied it is verified against the `wp_rest` action; use the `mira_rest_require_nonce` filter to require it for every request.
* API keys are stored in the WordPress options table and are only used in server-to-server requests with an `Authorization: Bearer` header.
* All event payloads are anonymised by design. Do not add personally identifiable information via the `mira_woocommerce_event_payload` filter unless your privacy policy covers it.
* Always serve the storefront and admin over HTTPS. Consider rate limiting and CORS rules at the API layer.
* The plugin is translation ready (text domain `mira-ai-shopping-companion`).

== Changelog ==

= 1.0.0 =
* Initial release: widget embed, settings page, shortcode, no-JS fallback, WooCommerce event tracking, product/status REST endpoints.

== Upgrade Notice ==

= 1.0.0 =
Initial release.
