=== CortexCommerce for WooCommerce ===
Contributors: cortexcommerce
Tags: woocommerce, ai search, structured data, seo, analytics
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.6.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Connect WooCommerce to CortexCommerce (free account needed): see AI-referred traffic, enrich products, publish structured data.

== Description ==

CortexCommerce for WooCommerce connects your store to [CortexCommerce](https://cortexcommerce.ai):

* **AI traffic:** a lightweight pixel reports page views, on-page engagement and add-to-cart activity, and the plugin reports paid orders, to your CortexCommerce Visibility page. No cookies and no browser storage.
* **Product enrichment:** CortexCommerce reads your catalog and writes back the enrichments you approve: descriptions, tags, SEO title and meta description, image alt text, and a new main image for a product that has no photo. WooCommerce, then Enriched products, lists every product it touched, with filters.
* **Structured data:** Product JSON-LD and Open Graph tags on product pages, switched on only where your theme doesn't already provide them.

This plugin needs a free CortexCommerce account to do anything: the plugin is the connector, and your account is where you see results and approve changes. Sign up at https://app.cortexcommerce.ai with your name, your store name and your email, then set a password from the email we send you.

== External services ==

This plugin talks to the CortexCommerce API at https://api.cortexcommerce.ai, operated by CortexCommerce. Nothing is sent until you click "Connect to CortexCommerce".

* **Connect:** your connect code, your store URL, a WooCommerce REST API key created for CortexCommerce, and your plugin, WordPress, WooCommerce and PHP versions and store currency. The plugin limits that key to reading and updating your products (with their variations, categories and tags) and its own CortexCommerce endpoints; it can't reach orders, customers or settings.
* **Product sync:** while connected, the plugin sends your products to CortexCommerce from your server, signed: the whole catalog once after connecting, in batches of 50 at a time that run one after the other until it is through (to keep going between batches the plugin sends a request to its own site, and no data leaves your store in that request), with the number of products in your store and how many have been sent so far, so your CortexCommerce account can show how far the first sync has come; then every 5 minutes the products that changed (a published product's WooCommerce REST API data with its variations, and its SEO title and meta description; for a draft, private or trashed product only its ID and status) and the IDs of products deleted for good. Nothing is sent when nothing changed.
* **Approved changes:** every hour while connected, and when you click Sync now, the plugin asks CortexCommerce which of your products have approved changes, fetches each one's approved values (name, descriptions, tags, SEO title and meta description, image alt text, and a new image for a product with no photo), writes them to your store, and reports back, signed, whether each product was updated, with its values before and after. Nothing is sent when nothing is waiting. The changes are written automatically with product-editing permissions only: not as you or any other user, and never with administrator rights. Before writing, the plugin checks that each answer is for the product being written, that the approval has not been written already, and that any image alt text is for one of that product's own images. Answers signed by CortexCommerce are also checked for your store and for this very request, and once one has been checked, unsigned answers are refused. Reading your products for the product sync works the same way: with permission to read products only, not as you or any other user. CortexCommerce cannot install, activate, update or remove plugins or themes, manage users or change your settings: it can only supply approved product content. If the user who connected the store is removed or can no longer manage WooCommerce, nothing is written.
* **New images:** CortexCommerce generates a product image only when you have turned on "Generate a product image" in your enrichment settings, only for a product that has no photo at all, and it never goes live until you approve it in your CortexCommerce account. Once approved, the plugin downloads that image file (up to 10 MB) from CortexCommerce (served from our private storage bucket on Google Cloud, storage.googleapis.com, through a short-lived link), adds it to your media library and sets it as the product's main image, so your store serves it from your own site. A product that already has a main image or a gallery picture is left alone. The copy in our storage exists for review and delivery and is deleted automatically after 30 days. On the Enriched products page, your browser shows an image still waiting for sync from the same kind of short-lived link.
* **Status panel and Enriched products page:** when you open WooCommerce, then CortexCommerce, or WooCommerce, then Enriched products, the plugin asks CortexCommerce, signed, for the counts on the panel and for the list of enriched products, sending the search text, the status and part filters and the page number you chose there. Answers are kept for up to five minutes, so the screens do not call CortexCommerce on every load.
* **Disconnect:** when you disconnect or deactivate the plugin, a signed "disconnected" or "deactivated" event.
* **Pixel script:** the storefront pixel script is loaded from https://cg.cortexcommerce.ai/pixel/v1/p.js (operated by CortexCommerce) on storefront pages other than checkout, payment and account pages.
* **Page views, leaves and add-to-cart:** each page view sends your store's pixel ID, the page type, the page path, the referring site's host name, the landing page's UTM tags, the search term on search pages, the product ID on product pages, the browser's language and time zone, a device-size class and page-load timing. When the shopper leaves the page, how long it was visible and how far they scrolled. When a product is added to the cart, the product (and variation) ID and quantity. No cookies and no localStorage or sessionStorage; the plugin sets no visitor identifiers of its own. The requests come from the visitor's browser, so CortexCommerce's servers also see the visitor's IP address and user agent, as with any web request; the browser's user-agent string is part of what is sent.
* **Order events:** sent from your server to CortexCommerce, signed, never from the shopper's browser and never on the checkout page. When an order is paid: the order number, status, created date, total, currency, coupon flag (yes or no) and line items (product, variation, quantity and line total) and, when WooCommerce's own order-attribution data is available, the traffic source type, referring site, UTM tags, entry page, session page and visit counts, and device type. For each refund: the order number, the currency, and the refund's number and amount. The plugin does not send customer names, email addresses, postal addresses or phone numbers.
* The plugin sends no names, email addresses, postal addresses or phone numbers, and the visitor's browser user-agent string is included with page-view, engagement and add-to-cart events. Nothing is stored in the browser. All of these store events, including order events, are kept for 13 months and then deleted automatically. No full IP address is stored; for abuse protection, truncated network prefixes may appear in CortexCommerce's operational logs. Switching the pixel off (the remote `pixel_enabled` setting from your CortexCommerce dashboard, or the `cortexcommerce_pixel_enabled` filter) stops page-view, engagement and add-to-cart reporting only; order events keep sending until you disconnect the store.

Terms of service: https://cortexcommerce.ai/terms
Privacy policy: https://cortexcommerce.ai/privacy

== Installation ==

1. In WordPress, go to Plugins, then Add New, and search for "CortexCommerce for WooCommerce". Click Install Now, then Activate. WooCommerce must be active.
2. Sign up for a free CortexCommerce account at https://app.cortexcommerce.ai with your name, your store name and your email. Set a password from the email we send you.
3. In your CortexCommerce account, choose Add store, then WooCommerce, and copy the connect code.
4. In WordPress, go to WooCommerce, then CortexCommerce, paste the code and click "Connect to CortexCommerce".
5. The status panel shows what CortexCommerce has done for your store and links to your dashboard.

== Frequently Asked Questions ==

= Do I need an account? =

Yes. The plugin needs a free CortexCommerce account: it connects your store to that account, and without one it has nothing to report to. Sign up at https://app.cortexcommerce.ai with your name, your store name and your email, then set a password from the email we send you.

= Does it cost anything? =

The plugin is free, and so is the account you sign up with. CortexCommerce also has paid plans and credit packs for the enrichment and publishing services; you only pay for those by card through Stripe Checkout if you choose to. Current prices are on https://cortexcommerce.ai/pricing. Merchants in Canada pay in CAD plus provincial tax at checkout; everywhere else pays in USD with no tax.

= What data leaves my store? =

Nothing is sent until you click "Connect to CortexCommerce". After that, your products (with their variations, categories, tags, and SEO title and meta description) are sent from your server, signed. The storefront pixel reports page views, time on page, scroll depth and add-to-cart events: the page path, the referring site, campaign tags, search terms, product and quantity, browser language and time zone, device class and page-load timings. It sets no cookies and uses no browser storage. Paid orders are sent from your server with the order number, status, created date, total, currency, coupon flag, line items and, when WooCommerce has it, order-attribution data; a refund sends only the order number, currency, and the refund's number and amount. Opening the CortexCommerce screens in wp-admin asks CortexCommerce for the status numbers and the enriched-product list, with the search text and filters you use there, and an approved new image for a product without a photo is downloaded from CortexCommerce into your media library, so your store serves it from your own site. No customer names, email addresses, postal addresses or phone numbers are sent. The full list is under "External services" above, and our privacy policy is at https://cortexcommerce.ai/privacy.

= Can I stop the data leaving? =

Yes. Disconnect on WooCommerce, then CortexCommerce, or deactivate the plugin. The plugin revokes the WooCommerce API key it created and tells CortexCommerce.

== Screenshots ==

1. Connect in one step: paste the code from your CortexCommerce account and click Connect. Nothing is sent before that click.
2. WooCommerce, then CortexCommerce: products synced, enriched, live on your site and waiting for your review, with Sync now to write approved changes straight away.
3. WooCommerce, then Enriched products: every product CortexCommerce enriched, its status, the parts that were updated, and links to edit it or view it on your store.

== Upgrade Notice ==

= 1.6.0 =
The first sync now runs continuously instead of a few hundred products every 5 minutes, and your CortexCommerce account shows its progress from the first products read.

= 1.5.0 =
Approved changes are now written with product-editing permissions only, never as an administrator, and each one is checked for the right product and approval before it is written.

= 1.4.0 =
The first sync after connecting runs faster, and your CortexCommerce account shows how many of your products have arrived.

= 1.3.1 =
Documentation only: the readme now lists every call the plugin makes to CortexCommerce, including how a new product image is generated, approved and delivered. No change in behaviour.

= 1.3.0 =
A new Enriched products page under WooCommerce lists every product CortexCommerce enriched, and an approved new image now becomes the main image of a product that has no photo. A product with a photo is never changed.

= 1.2.0 =
Approved changes are now written to your store every hour, or straight away with the new Sync now button. Works on hosts that block incoming requests. A new status panel shows what CortexCommerce has done for your store, and a notice tells you when your hosting is blocking our connection.

== Changelog ==

= 1.6.0 =
* The first sync runs continuously: the plugin starts its next run itself while products are left to send, instead of a few hundred products every 5 minutes.
* Products that are not published (drafts, private, pending, trashed) are no longer built and sent in full; only their status is sent.
* Each batch is up to 50 products, and your CortexCommerce account shows the sync's progress from the first products read.
* Hosts that refuse the plugin's request to itself only lose speed: the 5-minute schedule still sends everything.

= 1.5.0 =
* Approved changes are written with no user and product-editing permissions only, for the product being written. They no longer run as the user who connected the store, and administrator capabilities (settings, plugins, themes, users, unfiltered HTML) are refused for the whole write, whatever another plugin grants.
* Each approved change is checked before it is written: once CortexCommerce signs its answers, it must be signed for your store, name the product being written and answer this very request. An approval already written is never written again (it is reported again instead), and alt text is written only on the product's own images. Fields the plugin does not write are ignored and named in the log.
* The product sync reads your products with permission to read products only, no longer as the user who connected the store.
* The alt-text route now accepts only WooCommerce product images (a product's or variation's main image, a gallery image, or an image uploaded from the product editor, for any product that is not in the trash). Any other image in the media library is refused, so the CortexCommerce key cannot change it.
* Works with WooCommerce 11.2.2, which authenticates API keys later in a request: the CortexCommerce key is still limited to products and the plugin's own endpoints at that point.
* Readme: External services says how approved changes are checked and what CortexCommerce cannot do.

= 1.4.0 =
* The first sync after connecting runs faster: while products are left to send, the next batch is queued straight away.
* Product sync now includes the number of published products in your store, so your CortexCommerce account can show how many have arrived out of the total. Readme: External services says so.

= 1.3.1 =
* Readme: External services now covers the status panel, the Enriched products page and new-image delivery, and says when an image is generated, that you approve it first, and that your store serves it from your own site.
* Tested with WooCommerce 11.2.

= 1.3.0 =
* New Enriched products page under WooCommerce: every product CortexCommerce has enriched, with its status (Live, Approved or Waiting for review) and which parts were updated. Search by name, filter by status or by part, and jump to the product's edit screen or its page on your store. The Enriched tile on WooCommerce → CortexCommerce now opens it.
* New images: an approved generated image becomes the main image of a product that has no photo at all. It is downloaded from CortexCommerce's storage into your media library, once; a product with a main image or a gallery picture is left alone.

= 1.2.1 =
* New CortexCommerce screen: clear links to create your account and get your connect code, and an Open dashboard button at the top once you're connected.

= 1.2.0 =
* Sync: changes you approve in CortexCommerce are written to your store every hour, or straight away with the new Sync now button on WooCommerce → CortexCommerce, which also shows each sync live. Works on hosts whose firewall blocks incoming requests.
* Status panel: WooCommerce → CortexCommerce now shows products synced, enriched, live on your site and waiting for your review, with a link to your dashboard.
* Hosting notice: when your host is blocking our connection, the panel says so and links to a guide on how to fix it.

= 1.1.0 =
* Product sync: the plugin now sends your catalog to CortexCommerce every 5 minutes, so it works on hosts whose firewall blocks incoming requests. It no longer registers WooCommerce product webhooks, and removes the ones version 1.0.0 created.
* The storefront pixel loads CortexCommerce's hosted script and also reports on-page engagement and add-to-cart; paid orders and refunds are sent as signed order events.

= 1.0.0 =
* First release: connect a WooCommerce store to CortexCommerce from a one-time code.
* AI-traffic pixel for the CortexCommerce Visibility page (no cookies, no browser storage).
* Product access for CortexCommerce through a WooCommerce REST key the plugin limits to reading and updating products.
* SEO title and meta description write-back (Yoast SEO, Rank Math, or the plugin's own fields).
* Product JSON-LD, Open Graph and canonical tags, switched on per store by the CortexCommerce Visibility scanner.
