=== Zilco ===
Contributors: signitive
Tags: ai, chatbot, product search, catalog, woocommerce
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 8.1
Stable tag: 0.1.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Sync your WooCommerce catalog to Zilco and embed an AI assistant that answers shopper questions using your real products.

== Description ==

Zilco turns your WooCommerce catalog into an AI shopping assistant. The plugin keeps your
products in sync with the Zilco service and embeds a chat widget on your storefront, so
visitors can ask questions in their own words and get answers grounded in your actual
products, prices, stock, and categories.

**This plugin requires an account on the Zilco service (zilco.ai) to work.** See the
"External services" section below for exactly what data leaves your site and when.

= What it does =

* **Full catalog sync.** Push every product — including drafts and private products, which
  are sent as inactive — to Zilco on demand from the settings screen, on an hourly WP-Cron
  schedule, or from an external cron service via a token-protected endpoint.
* **Incremental sync.** When you create, edit, trash, restore, or delete a product, or when
  its stock changes, only that product is re-sent. Multiple edits within one request are
  collapsed into a single update.
* **Simple and variable products.** Variations are sent as variants of their parent product,
  with their own SKU, price, stock, and attribute values.
* **Rich mapping.** Titles, descriptions, categories, brands, attributes, images, GTIN/MPN,
  weight and dimensions, sale prices, and availability are mapped for you.
* **Storefront chat widget.** A small loader script is added to your theme's head. On a
  product page it tells the assistant which product the visitor is looking at.
* **Built for large catalogs.** Batched requests, request pacing, automatic retries on rate
  limits, database keepalive, and object cache flushing between batches. On hosts that
  support it, the cron endpoint responds immediately and finishes the sync in the background
  so reverse proxies never time out.

= What it does not do =

The plugin never writes to your products. It reads catalog data and sends it to Zilco. It
does not touch orders, customers, or any personal data of your shoppers.

== Installation ==

1. Install and activate WooCommerce 8.0 or newer.
2. Upload and activate this plugin.
3. Create a site in your Zilco dashboard and copy its secret sync API key (`sk_…`) and
   public widget key (`pub_…`).
4. In WordPress, go to **WooCommerce → Zilco** and paste the keys.
5. Tick **Enable catalog sync** and/or **Enable chat widget**. Both are off until you
   turn them on, and nothing is sent to Zilco before that.
6. Click **Run full sync** to push your catalog for the first time.

== External services ==

This plugin relies on Zilco, a third-party software-as-a-service platform operated by
SIGNITIVE SRL, to index your catalog and to generate assistant replies. The plugin is not
useful without it. Nothing is transmitted until you enter your Zilco API keys and explicitly
enable catalog sync or the storefront widget in the plugin settings; both options are
disabled by default.

**Service:** Zilco — https://zilco.ai
**Terms of use:** https://zilco.ai/service-terms
**Privacy policy:** https://zilco.ai/service-privacy

= Catalog sync (api.zilco.ai) =

*What is sent:* product data from your store — product and variation IDs, SKU, GTIN and MPN,
name, short description and description, permalink, image URLs, categories, brands,
attributes, price and sale price, currency, stock status and quantity, weight and dimensions,
publish status, and last-modified date. Your site's locale and the plugin version are sent
with each request, and your secret API key is sent as the request credential.

*When it is sent:* only while **Enable catalog sync** is on — when you click **Run full
sync**, when the hourly WP-Cron event runs (if you enable it), when the token-protected cron
endpoint is called, and whenever a product is created, updated, trashed, restored, deleted,
or has a stock change.

*What is not sent:* no order, customer, user, or site-visitor personal data is included in
catalog sync requests.

= Storefront chat widget (chat.zilco.ai) =

*What is sent:* while the widget is enabled, every storefront page load requests a loader
script from `chat.zilco.ai`, which means visitors' browsers contact Zilco directly and Zilco
receives the usual request metadata (IP address, user agent, referring page). Your public
widget key, the site locale, and — on product pages — the ID of the product being viewed are
passed to the widget. If a visitor opens the chat, the messages they type are sent to Zilco
to be answered.

*When it is sent:* on every storefront page view while **Enable chat widget** is on.

*Browser storage:* the widget sets no cookies, but it stores a chat session pointer in the
visitor's browser local storage so a conversation can be resumed. It expires after 7 days of
inactivity.

Because the widget causes your visitors' browsers to contact a third party and stores data in
their browser, you should mention Zilco in your own site's privacy and cookie notices before
enabling it. Zilco's platform privacy notice, including its sub-processors, is at
https://zilco.ai/service-privacy

== Frequently Asked Questions ==

= Do I need a paid Zilco account? =

You need a Zilco account. The plugin itself is free and does not require payment to install
or use, but it cannot function without the Zilco service.

= Can I use the plugin for sync only, without the chat widget? =

Yes. Catalog sync and the storefront widget are separate settings. Enable either one, both,
or neither. If you only want sync, leave the widget off and embed the widget yourself, or not
at all.

= Are drafts and private products sent to Zilco? =

Yes, but flagged as inactive so the assistant never recommends them. This is deliberate: if
unpublished products were skipped entirely, unpublishing a product in WooCommerce would leave
it visible in the assistant.

= My catalog is large and the full sync times out. What should I do? =

Use the cron URL shown on the settings screen with an external cron service. On hosts with
PHP-FPM the endpoint answers immediately and continues in the background. You can poll
progress by adding `&status=1` to that URL, and clear a stuck lock with `&unlock=1`.

= Do prices include tax? =

By default yes. There is a setting to send prices excluding tax if that matches how you
display prices.

= Is High-Performance Order Storage supported? =

Yes. The plugin declares HPOS compatibility. It never reads or writes orders.

= What happens when I uninstall the plugin? =

All plugin options, including your API keys and the cron token, are deleted, and the
scheduled sync event is removed. Data already indexed in Zilco is not deleted — remove it
from your Zilco dashboard.

== Screenshots ==

1. The settings screen under WooCommerce → Zilco: API keys, sync and widget toggles, last
   sync status, and the token-protected cron URL for external schedulers.
2. The chat widget open on a product page, answering questions about the synced catalog.

== Changelog ==

= 0.1.2 =
* Use the WordPress HTTP API (`wp_remote_request`) for all Zilco API calls instead of raw cURL.

= 0.1.1 =
* Security: encode the storefront widget config without JSON_UNESCAPED_SLASHES so a crafted
  public key cannot break out of the inline script tag.

= 0.1.0 =
* Initial release: full and incremental catalog sync, simple and variable product mapping,
  admin settings screen, WP-Cron schedule, token-protected cron endpoint, and storefront chat
  widget embed.
