=== ChatSell Widgets ===
Contributors: chatsell
Tags: chat, chatbot, product search, ecommerce, ai
Requires at least: 5.0
Tested up to: 6.9
Requires PHP: 7.4
Stable tag: 1.2.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Easy-to-use chat and product search widgets for WordPress sites. Add AI-powered customer support and product discovery to your site.

== Description ==

ChatSell Widgets brings powerful AI-powered customer support and product discovery to your WordPress site. Connect your site to your ChatSell account and embed fully customisable widgets in minutes.

**Chat Widget**

* Real-time AI-powered customer support
* Product recommendations and search
* Customisable appearance and behaviour
* Multiple positioning options
* Sound notifications and avatar display

**Product Search Widget**

* Lightning-fast product search
* Floating or inline positioning
* Product variant filtering
* Customisable styling
* Keyboard shortcut (press "/" to open)
* Responsive design

**Ask AI Widget**

* Let visitors ask questions answered from your knowledge base
* Floating button or inline embed
* Fully customisable appearance

**Key Features**

* Easy setup through WordPress admin — no coding required
* Shortcode support for flexible widget placement
* Customisable colours and positioning
* Product variant filtering
* Real-time WooCommerce product, page, and post sync (optional)
* Mobile-responsive design

= External Services =

This plugin connects to the **ChatSell service** (https://chatsell.co) to power the AI chat, product search, and Ask AI widgets. By configuring and enabling this plugin, the following data may be transmitted to ChatSell servers:

* Your ChatSell Site ID (stored locally, sent with API requests)
* Visitor chat messages and product search queries (processed by the ChatSell AI)
* WooCommerce product data and published page/post content (only when real-time sync is enabled)
* When you connect the plugin: your site address and name, WordPress and WooCommerce versions, plugin version, store currency, base country, site language, and published product count
* When you connect the plugin on a WooCommerce store: a read-only WooCommerce REST API key created by this plugin for ChatSell to read your catalogue. It is listed as "ChatSell (auto-generated)" under WooCommerce → Settings → Advanced → REST API, and this plugin deletes it when you disconnect.

Widget JavaScript files are loaded from the configured ChatSell frontend URL (default: https://chatsell.co).

This plugin also registers one read-only REST endpoint, `GET /wp-json/chatsell/v1/handshake`. It is used only while you are connecting the plugin, to confirm to ChatSell that the connection request came from this site. It returns the site name, whether WooCommerce is active, the plugin version, and whether a supplied one-time value matches the connection this site just started. It exposes no credentials or personal data.

* Terms of Service: https://chatsell.co/terms
* Privacy Policy: https://chatsell.co/privacy

== Installation ==

1. Upload the plugin files to the `/wp-content/plugins/chatsell-widgets` directory, or install the plugin through the WordPress plugins screen directly.
2. Activate the plugin through the 'Plugins' screen in WordPress.
3. Go to **Settings > ChatSell Widgets** and click **Connect to ChatSell**.
4. Approve the connection in ChatSell. You are returned to WordPress with everything configured — there is nothing to copy by hand.
5. Click **Sync now** to import your products, then enable and customise the widgets you want to use.
6. Use the shortcodes `[cswidgets_chat]`, `[cswidgets_search]`, and `[cswidgets_ask]` to place widgets anywhere on your site.

== Frequently Asked Questions ==

= How do I get my Site ID? =

You do not need to find it yourself. Click **Connect to ChatSell** on the settings screen and approve the connection; the Site ID and webhook secret are configured automatically. If you prefer, you can generate a pairing code in your ChatSell dashboard and paste that instead. Both are configured under "Advanced connection settings", where the Site ID stays visible. The stored webhook secret is never displayed there — the field only shows whether one is saved, so you can replace or clear it but not read it back.

= Does this plugin create a WooCommerce API key? =

Yes, on WooCommerce stores. When you connect, the plugin creates a **read-only** REST API key named "ChatSell (auto-generated)" so ChatSell can read your product catalogue — this saves you creating one by hand. You can see it under WooCommerce → Settings → Advanced → REST API, and the plugin deletes it when you disconnect.

= Do I need a ChatSell account? =

Yes. ChatSell is a Software as a Service (SaaS) platform. You need an account at https://chatsell.co to use this plugin.

= Can I customise the appearance? =

Yes. Colours, positioning, text labels, and behaviour are all configurable from the Settings > ChatSell Widgets page in WordPress admin.

= Can I use shortcodes to place widgets? =

Yes. Use `[cswidgets_chat]` for the chat widget, `[cswidgets_search]` for product search, and `[cswidgets_ask]` for the Ask AI button. Parameters can be passed to override settings on a per-placement basis. For visitor storage mappings, shortcode `dynamic_params` values are limited to mappings already saved in the admin settings.

= Do the widgets work on mobile? =

Yes, all three widgets are fully responsive.

= What is real-time sync? =

When enabled, WooCommerce product changes and published WordPress page/post changes are immediately forwarded to ChatSell so your AI and knowledge base stay up to date. Product sync requires WooCommerce and all real-time sync requires a webhook secret from your ChatSell dashboard.

== Screenshots ==

1. ChatSell dashboard — manage your AI chatbot, knowledge base, and analytics.
2. AI chat widget in action on a live storefront.
3. Ask AI widget — let visitors ask questions answered directly from your knowledge base.

== Changelog ==

= 1.2.1 =
* Reuse WooCommerce locale and currency in Product Search and Catalog instead of requesting chat capability configuration on every page.
* Stop loading the chat widget script when only Product Search is enabled.

= 1.2.0 =
* Redesign the settings screen around shopper-facing tasks with clearer navigation, grouped controls, and live widget previews.
* Add responsive layouts, accessible tab navigation, conditional settings, and a persistent save bar.
* Version admin CSS and JavaScript from their file modification times to prevent stale CDN and browser caches after plugin updates.

= 1.1.0 =
* Add one-click "Connect to ChatSell": approve once and the Site ID, webhook secret and service URLs are set up for you — nothing to copy by hand.
* Automatically create a read-only WooCommerce REST API key on connect, so there is no need to visit WooCommerce → Advanced → REST API. The key is named "ChatSell (auto-generated)" and is deleted when you disconnect.
* Send store details (currency, base country, language, product count) to ChatSell on connect so the assistant answers with the right currency and language.
* Add a "Sync now" button with a live progress bar for importing products.
* Add "Refresh connection" and "Disconnect" controls, and a pairing-code option for connecting from the ChatSell dashboard.
* Move Site ID, service URLs and webhook secret into an "Advanced" section; they are now filled in automatically.
* Report connection and sync failures in the admin screen instead of failing silently.
* Clear scheduled sync events on deactivate and uninstall.

= 1.0.5 =
* Sync published WordPress page and post changes to the ChatSell knowledge base through the existing real-time webhook.

= 1.0.4 =
* Share product discovery settings between Ask AI and Product Search.
* Send dynamic product parameters with Ask AI product questions.

= 1.0.3 =
* Send real-time product sync webhooks when WooCommerce product variation prices or stock are saved.

= 1.0.2 =
* Move admin CSS and JavaScript to separate enqueued files for standards compliance.
* Replace inline script config output with wp_add_inline_script for cleaner page output.
* Update default API and frontend URLs to production ChatSell service endpoints.
* Fix product sync webhook to use non-blocking HTTP request.
* Add external services disclosure to readme.
* Fix duplicate Plugin URI / Author URI in plugin headers.

= 1.0.1 =
* Align plugin version metadata for packaged releases.
* Add GitHub release pipeline support for distributable plugin zip files.

= 1.0.0 =
* Initial release.

== Upgrade Notice ==

= 1.2.1 =
Reduces unnecessary storefront requests for stores using Product Search without Chat.

= 1.2.0 =
Redesigned settings and cache-safe admin assets. Recommended for all users updating from an earlier version.

= 1.1.0 =
One-click store connection. Recommended for all users: connecting no longer requires copying a Site ID, a webhook secret, or WooCommerce API keys by hand.

= 1.0.5 =
Recommended for stores using Ask AI with WordPress pages and posts as knowledge sources.

= 1.0.3 =
Recommended for WooCommerce stores using variable products.

= 1.0.2 =
Standards compliance and production URL update. Upgrade recommended for all users.
