=== Reztart AI Newsletters for WooCommerce ===
Contributors: reztart
Tags: woocommerce, email marketing, newsletters, ai, openai
Requires at least: 6.2
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.0.8
WC requires at least: 6.0
WC tested up to: 10.8
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Generate individualized AI marketing emails for every WooCommerce customer — based on their real order history, country, last purchase, and spend.

== Description ==

**Stop sending the same blast email to every customer.** AutoNewsletterAI is a native WooCommerce plugin that uses GPT-4.1-mini and GPT-5 to write a fresh, individualized newsletter for every single recipient — based on their real order history, country, last-purchased product, total spend and recency. Two customers never see the same message. No merge-tag illusions. No bulk fingerprints that land in spam.

= What makes it different =

* **Truly individualized.** Every email is a fresh AI generation. Not a template with a {first_name} swap.
* **Reads your store directly.** Pulls from WooCommerce — customers, orders, products. No external sync, no extra cron jobs, no third-party newsletter platform.
* **HPOS-compatible.** Order queries go through `wc_get_orders()` so they work on both legacy and High-Performance Order Storage.
* **Per-row or bulk batch.** Generate one email at a time to fine-tune, or batch-generate 50+ in parallel with live progress polling.
* **Bring your own SMTP.** Uses your existing WordPress mail config (or any SMTP plugin like FluentSMTP / WP Mail SMTP). Your sender reputation stays in your hands.
* **Two AI models.** GPT-4.1-mini (fast workhorse, on every plan) or GPT-5 (premium reasoning, on paid plans).
* **Same account across platforms.** One AutoNewsletterAI login works on WordPress, OpenCart, PrestaShop and Shopify. Plan and quota are shared.

= What goes into every email =

* Country and language (auto-detected from billing address)
* Last purchased product — name, price, category
* Days since the last order — first-time vs returning customer messaging
* Total order count and average order value
* Cross-sell and up-sell hints from your product relations
* Your style + tone preset (modern / classic / minimal, formal / casual, emoji on/off)
* Your free-form additional instructions per campaign — e.g. *"Mention our Black Friday sale"*, *"Speak in Italian"*, *"Keep it under 80 words"*

= Compatibility =

* WordPress **6.0 — 6.7**
* WooCommerce **6.0 — 10.8** (HPOS supported)
* PHP **7.4, 8.0, 8.1, 8.2, 8.3, 8.4**
* Multi-language stores (Polylang / WPML coexistence — recipient language auto-detected from billing country)

= Pricing =

* **Free tier** — 5 generations / month, GPT-4.1-mini. Permanent free, no credit card.
* **Paid plans** — from $19/month, up to 10 000 generations/month. All paid tiers also unlock GPT-5. Cancel any time from the in-store Account tab.

Full plan details: [autonewsai.com/pricing](https://www.autonewsai.com/pricing)

= External services this plugin uses =

This plugin connects to two external services to operate. By installing and activating it, you agree to those services' terms.

* **AutoNewsletterAI backend** at `https://api.autonewsai.com` — the SaaS service that runs the AI generation, billing, and account management. Sends an HTTPS request per generation containing: the recipient's name and email, country, order summary fields you pick for the campaign, the products you chose, and your campaign instructions. [Terms](https://www.autonewsai.com/terms) · [Privacy Policy](https://www.autonewsai.com/privacy)

* **OpenAI** (used internally by the AutoNewsletterAI backend) — the language model that writes the email body. You don't talk to OpenAI directly from your WordPress site; the request flows through our backend. [OpenAI policies](https://openai.com/policies/)

* **Stripe** (used only when you upgrade) — Stripe Checkout is opened in a new tab; card details never touch your WordPress site or our backend. [Stripe terms](https://stripe.com/legal)

= Try the live demo =

We host a demo OpenCart admin (same feature set as WP) so you can click around without installing:

* URL: https://autodemo.autonewsai.com/admin/
* Username: `demo`
* Password: `demo`

Generation, send, and account mutations are blocked in the demo so you can explore risk-free.

== Installation ==

= Quick install =

1. In WP admin, go to **Plugins → Add New → Upload Plugin**.
2. Upload `autonewsletterai-<version>-wp.zip` and click **Install Now**.
3. Click **Activate**.
4. Open **WooCommerce → AutoNewsletterAI** (new submenu).
5. Click the **Account** tab and **Register** with your email. Verify the email link.
6. Click **Campaigns → + Add Campaign**, fill in the form, and click **Generate all**.

= Permissions =

Any user with the **`manage_woocommerce`** capability gets access automatically. Default roles that have it: **Administrator** and **Shop Manager**. For custom roles, grant `manage_woocommerce` via your role manager (User Role Editor, Members, etc.).

= Required PHP extensions =

* `curl` (always present)
* `json` (always present)

No additional extensions or composer packages required.

== Frequently Asked Questions ==

= Do I need an API key from OpenAI? =

No. AutoNewsletterAI runs its own backend that handles AI generation. You only need an AutoNewsletterAI account — sign up from the Account tab inside the plugin (free tier available, no credit card).

= Can I use this with my existing SMTP plugin (WP Mail SMTP / FluentSMTP / Postmark / SendGrid)? =

Yes. The plugin uses WordPress's native `wp_mail()` function, which any SMTP plugin can override. Configure your SMTP plugin as usual; AutoNewsletterAI will send through it automatically.

= Is it HPOS-compatible? =

Yes. The plugin declares `custom_order_tables` compatibility on activation and all order queries go through `wc_get_orders()`, so it works on both legacy `wp_posts`-based orders and the new HPOS tables.

= Does the plugin store my customers' data on your servers? =

No. The plugin reads customer + order data from your WooCommerce database at generation time only, sends it to our backend for the single generation request, and discards it server-side after. We retain only the *generated* email (subject + body) plus the recipient's email address on YOUR WordPress database — used to populate the Ready / History tabs. The full Privacy Policy: [autonewsai.com/privacy](https://www.autonewsai.com/privacy)

= Will my data train an AI model? =

No. The backend uses OpenAI's paid API, where their terms explicitly prohibit training on API customer inputs.

= What happens to my data if I deactivate / delete the plugin? =

Deactivation: nothing changes. Delete: WordPress runs `uninstall.php` which drops the plugin's two database tables (`{$wpdb->prefix}autonewsletterai_campaign` and `_campaign_customer`). Export your data first if you want to keep history.

= What if a generation fails? =

Failed (4xx / 5xx) generations do **not** count against your monthly quota. The recipient row stays in `failed` status with the error message visible in the History tab — you can re-click Generate to retry.

= Can I customize the email HTML template? =

The generated body IS the HTML. The AI writes the full `<html>...</html>` from scratch per recipient, matching the style/tone you picked. No separate template to maintain.

= Is there a free tier? =

Yes. 5 generations per month, GPT-4.1-mini model, with no expiration and no credit card required. Permanent — not a 14-day trial.

= How do I cancel a paid subscription? =

From the Account tab inside WP admin, click **Manage subscription** → opens Stripe's customer portal in a new tab. Cancel there; your access remains until the end of the paid period.

= Can I use the same account on multiple WordPress sites? =

Yes. Sign in with the same AutoNewsletterAI account on every site you own. Plan and monthly quota are shared across all sites (and across all four supported platforms — WP, OC, PS, Shopify).

== Screenshots ==

1. Dashboard — generated / sent / failed cards plus plan quota progress, all styled to match WP-admin conventions.
2. Campaign list — uses WordPress's standard list-table conventions for filtering, sorting and bulk actions.
3. Campaign builder (page 1) — recipient mode, style, tone, language selection.
4. Campaign builder (page 2) — product selection with cross-sell / up-sell / recent-products fallback chain.
5. Plans page — bundled catalog with side-by-side GPT-4.1-mini vs GPT-5 comparison.

== Changelog ==

= 1.0.8 (2026-06-01) =
* Send button enables on `status='generated'` regardless of prior send result — label flips to "Resend" for already-sent rows. (UI was stricter than the backend, which always allowed resend.)
* Minor copy fixes.

= 1.0.7 =
* API required fields backfilled at the payload layer: `offered_products[*].image` falls back to `wc_placeholder_img_src()`, `short_description` falls back to a single space if empty, `website_logo` falls back to WC placeholder → WP admin logo.

= 1.0.6 =
* Three-step product picker fallback: cross-sells/up-sells → recent excluding already-purchased → recent without exclusion. Plus diagnostic: error message now includes "Store has N published products total" when picker fails.

= 1.0.5 =
* `PayloadBuilder` rewritten to match the API contract — now sends `style_code` / `text_tone` / `offered_products` (was sending `style` / `tone` / `products` and getting 422). Plus `client_name`, `website_name/url/logo`, `purchased_products`, `color_palette`. Validation errors now surface `validationDetails` in the error message.

= 1.0.4 =
* `validate_callback` PHP 8 strict-mode fix — `is_numeric` is 1-arg but WP REST calls validators with 3 args. Replaced with internal `isNumericValue` wrapper.

= 1.0.3 =
* Plan upgrade locked until email is verified — UI banner + disabled buttons + REST backstop returning 403 `email_not_verified`.

= 1.0.2 =
* Force `/info` refresh on the Account tab when the user returns from Stripe Checkout via `?subscribed=1`. Same on the Plans tab on every render. Pulsing "Verify email" pill added to the in-plugin navbar when `email_verified=false`.

= 1.0.1 =
* Plans page now includes a 4-screenshot comparison panel (B2B SaaS sample + B2C e-commerce sample, two models each).

= 1.0.0 =
* Initial public release. Full Phase 1-4 feature set: campaign CRUD, recipient resolution (5 modes), single-row + batch generation, Ready + History + Dashboard pages, Plans catalog with model toggle, Stripe Checkout + billing portal + cancel + resume, defensive `Throwable` catch on every REST endpoint, demo-build flag.

== Upgrade Notice ==

= 1.0.8 =
Send-button state fix — the Send button now correctly enables for already-sent rows so you can resend without manual workarounds.
