=== SmartVitrines ===
Contributors: agti
Tags: woocommerce, recommendations, cross-sell, analytics, ecommerce
Requires at least: 6.7
Tested up to: 7.0
Requires PHP: 8.2
Requires Plugins: woocommerce
Stable tag: 2.0.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Behavioral product recommendations for WooCommerce. Requires a free SmartVitrines (AGTI Analytics) account.

== Description ==

SmartVitrines shows personalized product recommendations on your product and cart pages, tracks anonymous browsing and purchase events, and syncs order line items with the SmartVitrines service for attribution.

**What you get**

* Recommendation shelves on the single product page and cart
* Anonymous visitor/session tracking for behavioral recommendations
* Optional shortcodes for block themes: `[smartvitrines_recommendations]`, `[smartvitrines_cart]`
* Compatible with WooCommerce High-Performance Order Storage (HPOS)

**Account required**

You need a [SmartVitrines account](https://analytics.agti.eng.br/) (free tier available) and store API keys. After install, open **WooCommerce → SmartVitrines** and paste your Public Key and Secret Key from the AGTI Analytics dashboard.

**Catalog feed**

For catalog sync, install the companion [AG Google Shopping Feed](https://github.com/agtiengbr/aggoogleshopping-woocommerce) plugin (or any feed that matches your tenant `sku_field`) and paste the feed URL in the AGTI Analytics Dashboard.

== External services ==

This plugin connects to the SmartVitrines / AGTI Analytics service (SaaS). After you save your keys, the store and browsers contact:

* `https://api.analytics.agti.eng.br` — recommendations and event ingestion
* `https://analytics.agti.eng.br` — account, terms, and privacy documentation

**Data sent to the service**

* Public API key
* Product identifiers (SKU / product ID / GTIN, as configured)
* Random visitor and session identifiers
* Event type (view, click, add-to-cart, conversion)
* Order reference (order ID) for attribution

**Data not sent**

* Customer name, email, phone, or address
* Payment details
* Visitor IP address (not included in plugin payloads)

**Cookies and storage (front-end)**

The bundled SDK may set first-party cookies and localStorage entries: `sv_visitor_uid`, `sv_session_id`, `sv_session_at`, `sv_pageview_id`. These are anonymous UUIDs used for recommendations and analytics.

**LGPD / GDPR**

SmartVitrines is designed to minimize personal data: anonymous IDs and product/order references only. Store owners remain responsible for their privacy policy, legal basis, and any consent / cookie banner tools required in their jurisdiction (including Brazil’s LGPD and the EU GDPR). Suggested policy text is also offered under **Settings → Privacy** via the WordPress Privacy Policy Guide.

The SmartVitrines worker may call your store’s authenticated REST route `GET /wp-json/smartvitrines/v1/order/{id}` with `Authorization: Bearer {secret_key}` to fetch order line items (no customer PII). Without a configured secret key, that route denies access.

Terms of Use: https://analytics.agti.eng.br/termos-de-uso/
Privacy Policy: https://analytics.agti.eng.br/politica-de-privacidade/

== Installation ==

1. Install and activate WooCommerce (compatible with current WooCommerce releases; see plugin header for tested version).
2. Install and activate SmartVitrines.
3. Create an account at https://analytics.agti.eng.br/ and copy your store keys.
4. Go to **WooCommerce → SmartVitrines**, paste Public Key and Secret Key, choose the product identifier, and save.
5. (Recommended) Install the aggoogleshopping companion plugin, generate the XML feed, and set `xml_feed_url` in the AGTI Analytics Dashboard.
6. Set the tenant `platform_url` to your store URL so the service can reach the order REST endpoint when needed.

== Frequently Asked Questions ==

= Do I need a paid plan? =

No. A free SmartVitrines tier is available. Paid plans increase catalog and recommendation quotas. Billing is handled on the SmartVitrines site, not through this plugin.

= Does the plugin work without WooCommerce? =

No. WooCommerce must be installed and active (`Requires Plugins: woocommerce`).

= What is the order REST endpoint? =

`GET /wp-json/smartvitrines/v1/order/{id}` with `Authorization: Bearer {your secret key}` returns order totals and line items for the SmartVitrines worker. It does not expose customer billing or shipping personal data. Requests without a valid secret are rejected.

= How do I handle cookie consent? =

Configure your store’s consent / CMP tool as required by law. SmartVitrines does not replace a cookie banner. Document the `sv_*` cookies in your privacy policy (see Privacy Policy Guide content added by this plugin).

= Why is there an API URL field? =

Leave it empty in production (defaults to the official API). Only advanced or local development setups should override it.

= Where do I get support? =

Use the [SmartVitrines site](https://analytics.agti.eng.br/) or the WordPress.org support forum for this plugin after it is published.

== Screenshots ==

1. Settings page: connect your SmartVitrines public and secret keys.
2. Product recommendations on the single product page.
3. Cross-sell recommendations on the cart page.

== Changelog ==

= 2.0.2 =
* Remove unused Domain Path header (no bundled languages folder; translations via translate.wordpress.org).
* Remove unused get_sdk_script_url() (SDK is enqueued from local assets).

= 2.0.1 =
* WordPress.org review: remove bundled .po/.mo/.pot (translations via translate.wordpress.org).
* WordPress.org review: rename PHP classes from SV_* to SmartVitrines_* (prefix length requirement).

= 2.0.0 =
* Pageview-centric tracking: a `pageview_id` is generated per page load and carried on every event and recommendation request, matching SmartVitrines SDK v2.
* Automatic `page_view` event on each page open; add-to-cart and server-side recommendations now correlate to the current pageview.
* Bundled SDK updated to v2.0.0.

= 1.0.0 =
* Initial WordPress.org release.

== Upgrade Notice ==

= 2.0.2 =
Plugin Check: drop Domain Path header; remove unused SDK CDN helper.

= 2.0.1 =
WordPress.org compliance: class prefix and translation packaging fixes.

= 2.0.0 =
Requires SmartVitrines API v2 (pageview_id contract). Update the API before upgrading this plugin.

= 1.0.0 =
Initial release.
