=== FeedAgentX – Connector for FeedAgentX.com ===
Contributors: feedagentx
Tags: woocommerce, chatgpt, product feed, openai, feedagentx
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 8.1
Stable tag: 2.3.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Connect WooCommerce to FeedAgentX.com to prepare and validate product feeds for OpenAI Ads.

== Description ==

**FeedAgentX** is the official WordPress plugin that connects your WooCommerce store to [FeedAgentX.com](https://feedagentx.com).

It exposes your product catalog (titles, prices, stock, images, categories and variants) through a token-protected API. **FeedAgentX.com** fetches the catalog, validates it and formats it for the **OpenAI Stable product-feed schema**.

Use the CSV or hosted feed URL generated by FeedAgentX.com when adding a product feed in OpenAI Ads Manager. OpenAI account access, supported markets, feed processing and advertising approval are managed separately by OpenAI. Installing this plugin does not guarantee product placement or enable checkout.

This plugin does **not** process payments or orders.  
Catalog reads use a protected REST API accessible to clients holding your feed token. The token also allows sync acknowledgments and an ownership request; only a WordPress administrator can approve an ownership change.

**Key Features**
* 🔒 Secure, read-only REST API connection
* 🧠 Product data preparation for OpenAI product feeds
* 📣 Independent Ads and search eligibility controls
* ⚙️ JSON feed optimized for FeedAgentX.com schema
* 🕓 Full & Delta feed generation
* 🔑 Token-based authentication
* 🧾 Product change tracking (price, stock, category)
* 🧩 Lightweight and fully compatible with WooCommerce

---

### 🧠 What is FeedAgentX.com?

[FeedAgentX.com](https://feedagentx.com) is a SaaS platform that helps WooCommerce stores  
connect to **ChatGPT’s Agentic Commerce Protocol (ACP)** ecosystem.

It collects product data through this connector, validates required fields and creates a flat product feed. The hosted URL can be connected in OpenAI Ads Manager; CSV export and an optional configured SFTP transfer are also available. Review processing results in Ads Manager after submission. Checkout integration is separate and is not provided by this plugin.

---

== Installation ==

**Requirements**

* WordPress 6.2 or later
* PHP 8.1 or later
* WooCommerce 5.0 or later

**Steps**

1. Install the plugin from **Plugins → Add New** in your WordPress admin, or upload the `.zip` and activate it.
2. Make sure WooCommerce is installed and active.
3. Go to **FeedAgentX → Settings**.
4. Click **Generate token** to create a read-only API token.
5. Copy the API endpoints shown on the Settings page:
   * Full feed: `/wp-json/feedagentx/v1/feed/full`
   * Delta feed: `/wp-json/feedagentx/v1/feed/changes`
   * Health check: `/wp-json/feedagentx/v1/health`
6. Sign in at [FeedAgentX.com](https://feedagentx.com) and paste the site URL and token into the connect-store form.
7. Review brand, Ads eligibility and return settings, then run a full sync. Use the SaaS-generated CSV or hosted URL in Ads Manager; the WordPress endpoints contain the source catalog, not the flat upload format.

---

== Frequently Asked Questions ==

= ❓ Can I use this plugin without FeedAgentX.com? =
No. This plugin is designed exclusively for use with your verified FeedAgentX.com account.

= 🔐 How is access secured? =
All endpoints require a valid **Bearer Token**, generated in the plugin settings.  
Tokens can be revoked or regenerated anytime.

= 🧾 What data is shared? =
Only product catalog data — title, price, stock, SKU, brand, category, image URLs, and availability.  
No personal data, orders, or payments are processed.

= 💬 How does it connect to ChatGPT? =
FeedAgentX.com validates your catalog and creates a product feed. Connect the generated hosted URL or upload its CSV in OpenAI Ads Manager, then check the processing results there. Feed acceptance and advertising eligibility depend on OpenAI's account and product requirements.

= 💾 How often does it sync? =
FeedAgentX.com controls synchronization frequency and fetches your data automatically.

---

== External services ==

This plugin connects your WooCommerce store to **FeedAgentX.com**, a third-party SaaS platform operated by FeedAgentX. The plugin itself does **not** make outbound calls; instead it exposes a read-only REST API that the FeedAgentX.com service pulls from after you connect your store.

**What data is shared with FeedAgentX.com:**

* Product catalog data: titles, descriptions, prices, stock levels, SKUs, brands, categories, image URLs, product attributes, and variant data.
* Plugin and platform metadata: plugin version, schema version, WordPress / WooCommerce / PHP versions, store currency, and target country.
* No customer information, order data, or personal data is read or transmitted.

**When data is shared:**

* Only after a site administrator generates an API token in **FeedAgentX → Settings** and pastes it into a connected workspace at FeedAgentX.com.
* Every request must include a valid Bearer token. Tokens can be revoked from the plugin's Settings page at any time, which immediately stops all access.

**Service provider:**

* FeedAgentX.com — Privacy Policy: <https://feedagentx.com/privacy/>
* FeedAgentX.com — Terms of Service: <https://feedagentx.com/terms/>

---

== Server configuration (recommended) ==

The plugin writes diagnostic logs to `wp-content/uploads/feedagentx-logs/`.
The directory is protected from direct web access by `.htaccess` (Apache) and
`web.config` (IIS), which the plugin generates automatically.

**If your site runs on Nginx**, those files are ignored. Add the following block
inside your server config to deny direct access to the log directory:

`
location ~* /wp-content/uploads/feedagentx-logs/ {
    deny all;
    return 404;
}
`

The logs only contain route names, error messages, and migration events —
authentication tokens are never included in diagnostic logs — but production sites should
still block external reads.

---

== Security notes ==

* All endpoints require a Bearer token; tokens compare in constant time
  (`hash_equals`) and rotate from the admin UI.
* Authenticated requests have a per-token rate limit (default 120/min).
* Failed-auth requests have a per-IP rate limit (default 10/min) to defend
  against brute force and log spam.
* Logging defaults to INFO level with 14-day file retention.
* Log directory is protected with `.htaccess` + `web.config`; Nginx admins
  must add the rule above.

---

== Screenshots ==
1. FeedAgentX settings panel with token and endpoint URLs  
2. JSON feed preview  
3. Connection status screen showing successful sync with FeedAgentX.com

---

== Changelog ==

= 2.3.0 =
* Supports moving Ads settings to FeedAgentX, with explicit approval in WordPress before local Ads controls become read-only.
* Reports excluded category IDs, full paths and exact-term scope consistently in health and feed responses. Existing source category filters remain active.
* Shows the settings owner and links to FeedAgentX; preserves legacy controls for stores still managed in WordPress.
* Keeps Search and Checkout settings independent of Ads ownership. Health requests never change ownership.
* Aligns catalog counts with source filters and clears ownership metadata on uninstall.

= 2.2.0 =
* Stable OpenAI product schema: canonical is_ads_eligible, independent search/Ads controls and explicit return acceptance.
* Nine required fields; policies and countries are optional except where checkout requires them.
* Stable wc-ID identities survive SKU edits and prevent SKU reuse from replacing another item. Run a full SaaS sync after upgrading.
* Event-ID pagination and acknowledgments prevent same-second and multi-page change loss. The updated backend requires this version.
* Variation removal updates the parent, so remaining variants stay in the feed.
* Active-sale prices follow WooCommerce's displayed tax convention. Scheduled discounts are not published early.
* Actual brand resolution, GTIN checksum validation, variant options and public URL checks. Parent GTINs are not copied to every variant.
* Adds source IDs and explicit per-product overrides for reliable SaaS revalidation.
* Uses WooCommerce's native GTIN getter without PHP notices. Tested with WordPress 7.1 and WooCommerce 10.2.3.
* Clarifies the OpenAI Ads product-feed workflow and separate checkout eligibility requirements.

= 2.1.0 =
* OpenAI flat (file-upload) spec compliance: the feed now carries every required flat field.
* Eligibility flags are back as first-class settings — `is_eligible_search` / `is_eligible_checkout` are required by the spec; new optional `is_eligible_ads`. Store-wide defaults with per-product overrides on the product edit screen (Advanced tab).
* Brand is now emitted per product via the brand resolver (required field, max 70 chars).
* New per-variant data: scalar `gtin` + `mpn`, sale price window dates, weight + dimensions (with units), `is_digital`, pre-order `availability_date` (WooCommerce Pre-Orders).
* Availability enum aligned with the spec: `pre_order` (was `preorder`), new `unknown`; `discontinued` removed.
* Feed header now includes `store_country`, `target_countries` (new multi-select setting), and the seller block (name, URL, privacy policy, terms, return policy).
* Validator rewritten around the flat spec's 18 required fields and conditional rules; error paths use flat field names.

= 1.0.0 =
* Initial public release.
* Read-only REST API for the OpenAI Agentic Commerce Protocol (ACP) "Upcoming" schema (Product → Variants nested).
* Variant expansion: variable WooCommerce products emit one Variant per WC variation.
* Full feed (`/feed/full`) and cursor-based delta sync (`/feed/changes`) with explicit `/feed/changes/ack` endpoint.
* `Authorization: Bearer` token authentication, per-token rate limiter for authenticated requests, per-IP rate limiter for unauthenticated requests.
* Per-product brand resolver (Woo Brands, YITH, Perfect Brands, meta, attributes).
* File-based daily-rotated logger; log directory protected by generated `.htaccess` + `web.config`.
* Settings page with Connection / Feed / Brand / Diagnostics tabs.
* Clean uninstall: drops plugin table, removes options, clears scheduled events.
* Requires PHP 8.1+ and WooCommerce 5.0+.

---

== Upgrade Notice ==

= 2.3.0 =
Update FeedAgentX before transferring Ads settings. Installing this release alone does not transfer ownership or remove category filters. Existing catalog settings are preserved.

= 2.2.0 =
Update the API schema and worker, install this plugin, then run a full sync. Review brand, Ads eligibility and return settings. Use the SaaS-generated CSV or hosted URL in Ads Manager; the authenticated nested WordPress endpoint is not an OpenAI-ready flat feed.

= 2.1.0 =
Required update for the new OpenAI flat feed spec — restores eligibility flags, adds brand/seller/country fields, and rewrites validation. Review FeedAgentX → Feed Settings after updating.

= 1.0.0 =
Initial stable release — Connect WooCommerce to FeedAgentX.com and enable ChatGPT commerce integrations.

---

== License ==
This plugin is licensed under the GPL-2.0-or-later license.  
It only shares catalog data with your verified FeedAgentX.com account.  
No customer, order, or personal information is collected.

---

> “FeedAgentX — The WooCommerce connector for FeedAgentX.com.”
