=== ShopAssist Compare ===
Contributors: shopassist
Tags: woocommerce, product comparison, compare products, ai
Requires at least: 6.3
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 0.1.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Adds Compare buttons to your product cards. Shoppers pick two products and get an AI-generated side-by-side comparison with add-to-cart buttons.

== Description ==

Compare adds a "Compare" button to every product card on your shop and category pages, and optionally to product pages. When a shopper picks two products, a popup shows an AI-generated side-by-side comparison of the two, with add-to-cart buttons for both.

* One click to start: activate the plugin and click Connect. No account to create first, no API keys to paste.
* Buttons on shop and category listings by default; the product page button, placement and appearance are set in the Compare dashboard.
* See which orders followed a comparison in the Compare dashboard.
* Compatible with High-Performance Order Storage (HPOS) and with both the classic and the block-based cart and checkout.

This plugin is a connector to the hosted Compare service. The comparisons are generated by that service, and the plugin does not work without it. See "External services" below for exactly what is sent and when.

Your store must be publicly reachable from the internet over HTTPS to connect: while connecting, the Compare service calls your store back to confirm the request came from it. A store on localhost, on a private network or behind a password cannot connect; the plugin then shows a message on WooCommerce > Compare and changes nothing else on your site.

= Free trial and pricing =

Compare is a paid service with a free trial. The trial starts when your store connects for the first time; no payment details are asked for. It lasts 14 days or 500 generated comparisons, whichever comes first. Nothing is charged when the trial ends, because no payment method is on file. To keep using Compare, choose a plan in the hosted Compare dashboard, which you open from WooCommerce > Compare; settings and billing are managed there.

A plan covers a monthly amount of revenue from shoppers who compared: orders placed within 7 days of a comparison, counted per calendar month. When that amount is reached, the Compare buttons are hidden until the next month starts or until you move to a larger plan; Compare writes to the site's administration email address before and when that happens. Nothing is charged beyond the plan.

Without a subscription after the trial, or when a subscription is cancelled or unpaid, the hosted service stops answering for your store: the Compare buttons are no longer drawn and no comparisons are made. The plugin itself never switches anything off on your site and locks no feature locally; it stays connected, your settings and data are kept, and the buttons return as soon as a subscription is active. Disconnecting and connecting again does not start a new trial.

== External services ==

This plugin connects your store to the Compare service. It contacts two addresses, both operated by Compare:

**1. The Compare API (`https://compare.getshopassist.com`)**

The Compare API creates your Compare account, generates the comparisons and records which orders followed a comparison.

* When you click Connect or Reconnect (never before, and not on activation): your site address (home URL), the site's administration email address and a one-time random value are sent. The email address is used only for messages about your Compare plan, such as when its monthly limit is close. The API then calls your site back at `/wp-json/compare/v1/verify` (`/?rest_route=/compare/v1/verify` on sites with plain permalinks) to confirm the request really came from your site, and answers with a public key and a secret that the plugin stores in your database.
* When a shopper places an order after using Compare on your store, and when the status of such an order changes: the order id, order number, order total, currency, order status, creation time and the shopper's anonymous Compare visitor id are sent, signed with your secret. No names, addresses, email addresses, products or payment details are sent. Orders by shoppers who did not use Compare are not sent.
* When you click "Open dashboard": your browser is redirected to the API with your store's address (host name and install path) and a signature, which signs you in to the dashboard.
* When you deactivate or delete the plugin, or click Disconnect: a signed notice with the reason ("deactivated" or "uninstalled") is sent, so the service stops for your store.
* When WordPress checks for plugin updates (in the background about twice a day, and when you open the Plugins or Updates screen): the plugin asks `https://compare.getshopassist.com/woo/plugin/update.json` for the latest version, at most once every six hours, whether or not the store is connected. That request carries the plugin's version number and nothing else about your site. When you install an update, WordPress itself downloads the new version from the same address, with the request headers WordPress sends for any download (they include your site address).

**2. The Compare storefront script (`https://compare.getshopassist.com/widget/compare.js`)**

Once your store is connected, this script is loaded on the front end of your store. It draws the Compare buttons and the comparison popup. Running in the shopper's browser, it talks to the Compare API directly: it sends your public key, the ids of the products being compared, the page language and country, an anonymous random visitor id that it keeps in the browser's local storage, and usage events (button shown, comparison opened, add to cart). The Compare API reads your public product catalog through the WooCommerce Store API to build the comparisons.

No store or shopper data is sent before the store is connected, and nothing is sent after the plugin is deactivated, apart from the disconnect notice itself.

Service terms: https://www.getshopassist.com/compare/terms
Privacy policy: https://www.getshopassist.com/compare/privacy

== Installation ==

1. Install and activate WooCommerce.
2. Install and activate ShopAssist Compare. You land on WooCommerce > Compare.
3. Click Connect. The page says what is sent to the Compare service when you do.
4. Open your shop page: product cards now have a Compare button.
5. Click "Open dashboard" to change placement and appearance or to enable the button on product pages.

Your site must be publicly reachable from the internet over HTTPS. A local or private site (localhost, a development domain, a site behind a password) cannot connect.

== Frequently Asked Questions ==

= The connection failed. What now? =

The message on WooCommerce > Compare says what to fix. The usual causes are: the site is not public (local or staging site, password protection, maintenance mode), the site does not use HTTPS, or a security plugin blocks the WordPress REST API. Fix the cause and click Connect.

= The buttons do not show on my product cards =

Some themes and page builders draw product cards without the standard WooCommerce hooks. Place the button yourself with the `[compare_button]` shortcode inside the card template, `[compare_button id="123"]` for a specific product, or in PHP: `<?php if ( function_exists( 'compare_button' ) ) { compare_button(); } ?>`.

= Does it work with variable products? =

Yes, the comparison is made for the product as a whole. Adding a variable product to the cart from the popup depends on a variation being chosen.

= I copied my store to a staging site =

Compare notices that the site address changed and pauses itself on the copy, so test orders are not reported as real ones. Click Reconnect on the copy only if you want it to be its own Compare store.

= How do I stop using Compare? =

Deactivate the plugin, or click Disconnect on WooCommerce > Compare. Compare is told to switch the service off for your store. If you activate the plugin again and click Reconnect, your store comes back with its earlier data and settings. Deactivating or disconnecting does not cancel a paid subscription: cancel it first under Manage subscription in the Compare dashboard, or delete the plugin.

= What happens to my data when I delete the plugin? =

Deleting the plugin tells Compare the store is gone and removes the plugin's settings (the public key, the secret and the connected site address). A paid subscription is cancelled at once and nothing further is charged. The data Compare holds for the store is deleted 90 days later unless you connect the store again; write to us to have it deleted sooner. The anonymous visitor id stored on orders (`_compare_vid`) stays with your order history.

== Screenshots ==

1. Compare buttons on product cards, with one product picked.
2. The comparison popup: two products side by side, a recommended pick and add-to-cart buttons.
3. Settings in the Compare dashboard: where the buttons appear and how they look.
4. The Comparisons report: the products shoppers compare most.
5. The Revenue report: orders placed by shoppers who compared.

== Changelog ==

= 0.1.2 =
* The store no longer connects on activation. It connects when you click Connect on WooCommerce > Compare, and that page says what is sent.

= 0.1.1 =
* Connecting sends the site's administration email address, so Compare can write when a plan's monthly limit is close.

= 0.1.0 =
* First version.
* Updates arrive on the WordPress Plugins screen, like those of any other plugin.
