=== TicketZero ===
Contributors: ccconsultinggmbh
Tags: live chat, chat, support, woocommerce, customer service
Requires at least: 5.8
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 0.4.6
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Connect your website to TicketZero in one click: embed live chat and (with WooCommerce) sync order and customer data.

== Description ==

TicketZero is an AI-powered customer service inbox. This plugin connects your WordPress website to your TicketZero account:

* **Live chat without code:** Pick your widget and it is embedded in the right place. No theme editing.
* **One-click connection:** You are briefly redirected to TicketZero, confirm, and come back already connected. No copying of keys.
* **With WooCommerce (optional):** Syncs order and customer data so the AI can answer order-status questions and suggest matching products.

A TicketZero account is required (free trial at https://ticketzero.de).

== External services ==

This plugin connects your website to **TicketZero** (https://ticketzero.de), an external SaaS service operated by CC Consulting GmbH. Without a TicketZero account the plugin has no function. During operation, data is exchanged with ticketzero.de:

1. **One-click connection (connect handshake).** When you click "Connect to TicketZero", you are redirected to `https://ticketzero.de/connect/wordpress`. This passes your website URL (`home_url`), your website name (`get_bloginfo( 'name' )`), a return URL back into your wp-admin, and a random state value. After you confirm, you come back with a workspace reference and a connection token. Triggered only by your explicit action in the admin area.

2. **WooCommerce synchronization (optional).** When you click "Connect shop products", the plugin creates a WooCommerce REST API key (read_write) and sends your shop URL (`home_url`), this consumer key and consumer secret together with your connection token to `https://ticketzero.de/v1/public/wordpress/woocommerce`. TicketZero then uses this key to read product, order and customer data via the WooCommerce REST API, so the AI assistant can answer order-status questions and suggest matching products. Triggered only by your explicit action in the admin area.

3. **Front-end chat widget.** As long as the connection is active and live chat is enabled, the plugin loads the loader script `https://ticketzero.de/widget.js` on the public pages of your website (with your workspace and, if set, widget reference as query parameters). When visitors use the chat, their messages and chat-related data are transmitted to and processed by TicketZero.

4. **Cart handoff to checkout.** If a visitor adds products to the cart inside the chat (on ticketzero.de) and proceeds to checkout, TicketZero passes the selected items base64url-encoded in a return URL to your shop domain (`?tz_checkout=...`). The plugin reads these items and adds them to the visitor's WooCommerce cart.

TicketZero is a separate external service. Its use is subject to:

* Terms of Service: https://ticketzero.de/legal/agb
* Privacy Policy: https://ticketzero.de/legal/datenschutz

== Installation ==

1. Upload and activate the plugin.
2. In the "TicketZero" menu, click "Connect to TicketZero".
3. Confirm at TicketZero and choose a widget.
4. Done &ndash; the live chat appears on your website.

== Frequently Asked Questions ==

= Do I need a TicketZero account? =

Yes. This plugin is a connector to the TicketZero service. You can start a free trial at https://ticketzero.de. Without an account the plugin has no function.

= Does it work without WooCommerce? =

Yes. The live chat works on any WordPress site. The product, order and customer sync is optional and only applies if WooCommerce is active.

= What data is sent to TicketZero? =

See the "External services" section above for the exact data exchanged and when.

== Changelog ==

= 0.4.6 =
* Admin styles and scripts are now enqueued as separate files instead of being printed inline. Page assets load only on the plugin screen.
* All PHP declarations, transients and internal parameters use the full `ticketzero` / `TicketZero` prefix. Stored settings are unaffected.

= 0.4.5 =
* WooCommerce: disconnecting the shop now also notifies TicketZero, so the shop no longer shows as "connected" there after you disconnect it here. The website connection stays intact.

= 0.4.4 =
* Metadata: distinct Plugin URI and Author URI (directory requirement). No functional changes.

= 0.4.3 =
* Readme rewritten in English and marked compatible with the current WordPress version (directory requirement). No functional changes.

= 0.4.2 =
* Readme: added an "External services" section (which data is sent to ticketzero.de and when, including Terms and Privacy links).
* Security: output on the admin page is consistently escaped at the point of output.
* Security: the cart parameter for the checkout handoff is now read in a sanitized way.
* After activation you are redirected to the local plugin settings page (instead of straight to an external site).
* The front-end loader script is now enqueued properly via wp_enqueue_script (async/defer via filter).

= 0.4.1 =
* Variable products in the chat cart: selected variants (size/colour) are correctly carried over during the checkout handoff (the attribute mapping is derived from the variant itself).

= 0.4.0 =
* Cart & checkout: customers can add suggested products to the cart directly in the chat and proceed to checkout (the chat hands the cart over to your WooCommerce checkout).

= 0.3.1 =
* WooCommerce connection: calmer, clearer messages if the shop cannot be connected at the moment.

= 0.3.0 =
* WooCommerce: "Connect shop products" in one click. The plugin creates the REST key itself and passes it to TicketZero (no more manual copying).

= 0.2.0 =
* Branded admin page, widget selection directly in WordPress, automatic connection after activation.

= 0.1.0 =
* First version: one-click connection and live chat embedding.
