=== HelpStack for WooCommerce ===
Contributors: nejcar20
Tags: woocommerce, support, live chat, help desk, ai chatbot
Requires at least: 6.4
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 0.2.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Connect your WooCommerce store to HelpStack for AI-powered customer support, order lookups, and a live chat widget.

== Description ==

HelpStack for WooCommerce connects your store to your HelpStack account so the HelpStack AI assistant can answer customer questions about their orders (status, tracking, contents) directly inside your chat widget, and so your support team can see order context alongside every conversation.

Setup takes two steps:

1. Generate a pairing code from your HelpStack dashboard.
2. Paste the code into **WooCommerce > HelpStack** and click Connect.

The plugin creates a **read-only** WooCommerce REST API key on your behalf (the same mechanism WooCommerce itself uses under WooCommerce > Settings > Advanced > REST API) and sends it to HelpStack together with your pairing code. HelpStack never receives write access to your store.

== External services ==

This plugin connects your site to the HelpStack service (helpstack.eu) to enable the order-lookup and support features described above.

When you click "Connect" on the HelpStack settings page (WooCommerce > HelpStack), this plugin sends an HTTPS request to `https://helpstack.eu/api/woocommerce/connect` containing:

* The pairing code you entered — used once to identify your HelpStack account, and never stored by this plugin.
* Your store's URL (via WordPress's `home_url()`).
* A newly generated, read-only WooCommerce REST API consumer key and consumer secret, so HelpStack can subsequently read order and customer data from your store via the standard WooCommerce REST API.

This request is only made when you actively click the Connect button.

Once connected, this plugin also makes the following requests to HelpStack:

* **Storefront chat widget** — when you enable "HelpStack chat widget on my storefront" (WooCommerce > HelpStack), every storefront page loads the script `https://helpstack.eu/api/woocommerce/widget.js`, with your store's URL and site locale passed as query parameters, so HelpStack can render the correct chat widget for your customers.
* **Support Inbox** — opening the "HelpStack Inbox" admin page sends a server-side request to `https://helpstack.eu/api/conversations` to retrieve a list of your recent support conversations (customer name, a short preview of the last message, channel, status and timestamp), which the plugin then renders as a normal WordPress admin table. Nothing from HelpStack is embedded in the page.
* **Unread count** — while your store is connected, the plugin requests `https://helpstack.eu/api/conversations/unread-count` to show an unread badge on the "HelpStack Inbox" item in the admin menu. The result is cached for 30 seconds, so this runs at most twice a minute while you are working in wp-admin.

The last two requests are authenticated with a short-lived (5 minute) signed token containing the current WordPress user's name and email address, so HelpStack knows which connected store, and which team member, is asking. The token is generated on the server for each request, sent only in an HTTP `Authorization` header, and is never exposed to the browser or placed in a URL.

Outside of an explicit Connect click, an enabled storefront widget, and the inbox/unread requests described above, the plugin makes no other outbound network calls, and includes no bundled analytics or tracking of any kind.

By using this plugin and connecting your store, you agree to HelpStack's:

* Terms of Service: https://helpstack.eu/terms
* Privacy Policy: https://helpstack.eu/privacy

== Installation ==

1. Upload the plugin files to the `/wp-content/plugins/helpstack-for-woocommerce` directory, or install the plugin through the WordPress "Add Plugins" screen directly.
2. Activate the plugin through the "Plugins" screen in WordPress.
3. Make sure WooCommerce is installed and active — this plugin requires it.
4. Go to **WooCommerce > HelpStack**.
5. Paste the pairing code from your HelpStack dashboard and click **Connect**.

== Frequently Asked Questions ==

= Does this plugin give HelpStack write access to my store? =

No. The WooCommerce REST API key this plugin creates is scoped to read-only permissions, the same as any other read-only key you could create yourself under WooCommerce > Settings > Advanced > REST API.

= What happens if I deactivate the plugin? =

Deactivating the plugin does not revoke the WooCommerce REST API key it created. To fully disconnect, also delete the corresponding key from WooCommerce > Settings > Advanced > REST API and disconnect the store from your HelpStack dashboard.

= Where is my pairing code? =

Pairing codes are generated from your HelpStack dashboard, under your store's WooCommerce integration settings.

= Where do I turn on the storefront chat widget? =

Go to WooCommerce > HelpStack once your store is connected, and check "Enable HelpStack chat widget on my storefront".

= Where do I read and reply to support conversations? =

Once connected, the "HelpStack Inbox" page in the WordPress admin menu lists your recent conversations, so you can see at a glance who is waiting on a reply. Selecting a conversation opens it in HelpStack, in a new tab, where you reply to it.

== Screenshots ==

1. The HelpStack chat widget on your WooCommerce storefront, ready for customer questions.
2. The HelpStack Inbox inside WordPress, listing your recent support conversations.
3. The HelpStack settings page under WooCommerce: connect your store and turn on the storefront widget.
4. Customizing the chat widget's appearance (color, position, launcher icon) from your HelpStack dashboard.

== Changelog ==

= 0.2.0 =
* The HelpStack Inbox page no longer embeds HelpStack in an iframe. It now retrieves your recent conversations over the HelpStack API and renders them as a native WordPress admin table; selecting one opens it in HelpStack in a new tab.
* Access tokens are now generated per request, live for 5 minutes instead of 12 hours, and are sent only in a server-side request header — never in a URL.
* Reconnecting a store no longer resets your storefront-widget setting.

= 0.1.2 =
* Add an unread-conversation count badge to the HelpStack Inbox item in the admin sidebar, so you can see unread at a glance without opening the inbox.

= 0.1.1 =
* Embedded Support Inbox: extend the SSO token lifetime to 12 hours so the inbox stays usable for a full work session.

= 0.1.0 =
* Initial release: plugin scaffold, pairing-code connect flow, storefront chat widget, embedded Support Inbox, and uninstall cleanup.

== Upgrade Notice ==

= 0.2.0 =
The Support Inbox is now a native WordPress admin screen backed by the HelpStack API, instead of an embedded iframe.

= 0.1.2 =
Adds an unread-conversation badge to the admin sidebar.

= 0.1.1 =
Keeps the embedded Support Inbox authenticated for a full session.

= 0.1.0 =
Initial release.
