=== Flowgration – CRM + Email Marketing for WooCommerce ===
Contributors: flowgration
Tags: crm, email-marketing, marketing-automation, woocommerce, automation
Requires at least: 6.0
Tested up to: 7.0
Requires PHP: 8.1
WC requires at least: 8.0
WC tested up to: 9.9
Stable tag: 1.0.1
License: GPL v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

CRM + Email Marketing for WooCommerce. Auto-build your CRM from orders, then automate email, SMS & WhatsApp. Free up to 500 contacts.

== Description ==

**Flowgration is the all-in-one CRM + Email Marketing platform built for WooCommerce stores.** Install the plugin, click Connect, and your CRM is ready in under 60 seconds — built automatically from your real orders, customers, products and form submissions. No CSV imports. No manual data entry. No long implementation.

Then use visual drag-drop journeys to automate the campaigns that recover revenue and grow your store:

* Welcome series (post-signup)
* Post-purchase upsell
* Abandoned cart recovery
* Win-back / re-engagement
* Repeat purchase nudges

**ALL CHANNELS IN ONE PLAN. NOT FOUR SEPARATE TOOLS.**

Email + SMS + WhatsApp. CRM + Marketing Automation. Analytics + Lead Scoring. Booking. All for €39/month — vs. HubSpot at €999+/month.

---

= Auto-Built CRM from WooCommerce =

The plugin reads your WooCommerce orders, customers, products, coupons, subscriptions, bookings, and abandoned carts, then automatically creates your CRM pipeline, stages, and custom fields — shaped to match your actual store data. When you add a new form or custom field, Flowgration notices and re-syncs.

Supported forms: Gravity Forms, WPForms, Contact Form 7, Ninja Forms, Forminator, Elementor Forms, Fluent Forms, Formidable, SureForms.

Historical backfill lets you import the last 90 days, 12 months, or your entire history so your CRM is populated from day one.

= Visual Drag-Drop Journey Builder =

Build automations without code. Drag triggers, actions, and conditions onto a visual canvas:

* **Triggers:** contact_created, order_paid, form_submission, tag_added, cart_abandoned, custom_event
* **Actions:** send email, send SMS, send WhatsApp, add/remove tag, update lead score, wait/delay, A/B test split, conditional branch

See real-time statistics — sends, opens, clicks, conversions — directly on the journey canvas.

= Email + SMS + WhatsApp in One Plan =

Connect your preferred email provider: SMTP, Brevo, Mailgun, Postmark, SendGrid, or AWS SES. Send transactional and marketing emails from the same platform. Add SMS and WhatsApp to any journey without a separate subscription. Drag-drop email templates with a 98%+ delivery rate.

= Analytics and Revenue Attribution =

Power-BI-style dashboards. Revenue attribution by campaign, journey, and channel. Drill-through to individual contact timelines. Custom report recipes for any metric your store tracks.

= Lead Scoring and Segmentation =

Automatic lead scoring based on purchase behaviour, RFM signals, form submissions, and custom events. Segment contacts by purchase history, product category, lifecycle stage, custom field value, or any combination. Segments update in real time as your store data changes.

= Booking Integration =

Built-in booking calendar replaces Calendly. Teams can own their availability and embed booking links into journeys — no separate subscription needed.

= Multi-Workspace and Team Roles =

Invite teammates, assign roles and permissions, and manage multiple brands or client stores from a single Flowgration account. Agencies can manage all their WooCommerce clients from one dashboard.

= Pricing (Flowgration backend — plugin is free and GPL) =

The WordPress plugin is free, open-source (GPL v2), and listed on WordPress.org. The Flowgration backend that powers the CRM, journeys, and multi-channel sending has the following plans:

* **Free** — up to 500 contacts, core CRM + basic automations
* **Core €39/month** — unlimited contacts, email + SMS + WhatsApp, visual journeys
* **Growth €79/month** — advanced analytics, custom fields, A/B testing
* **Plus €179/month** — multi-provider email, full API access, webhooks, priority support
* **Full Suite €399/month** — everything, white-label, dedicated SLA support

Start for free at [flowgration.com](https://flowgration.com).

= Requirements =

* WordPress 6.0 or higher
* WooCommerce 8.0 or higher
* PHP 8.1 or higher

== Installation ==

1. Upload the plugin to `/wp-content/plugins/flowgration` or install via the **Plugins** screen in WordPress.
2. Activate the plugin through the **Plugins** screen.
3. Go to **Settings → Flowgration**.
4. Choose your connection mode:
   * **I'm new to Flowgration:** confirm the admin email and click **Connect**. Open the activation link in your inbox, then paste the API key shown on the Flowgration success page back into the plugin. Your CRM — pipeline, stages, and custom fields — is created automatically.
   * **I already have a Flowgration account:** paste your existing `sk_live_…` API key and click **Connect**. Then click **Open Flowgration to map fields** to confirm the suggested mappings.
5. (Optional) Open **Settings → Flowgration → Overview** and click **Backfill historical data** to import your past orders and customers.

No paid onboarding required. No SQL. Customer rows never leave your site during initial setup — only field counts and shapes are sent.

== Frequently Asked Questions ==

= Do I need a Flowgration account before installing? =

No. The default flow ("I'm new to Flowgration") creates your account automatically from the data the plugin discovers — pipeline, stages, custom fields, and a fresh API key are all created on the first click of the magic-link activation email.

= Is the plugin free? =

Yes. The plugin is free and GPL v2 licensed. The Flowgration backend has a free tier (up to 500 contacts) and paid plans starting at €39/month. See [flowgration.com/pricing](https://flowgration.com/pricing) for details.

= What are the pricing plans? =

* **Free** — up to 500 contacts, core CRM + basic automations
* **Core €39/month** — unlimited contacts, email + SMS + WhatsApp, visual journey builder
* **Growth €79/month** — advanced analytics, custom fields, A/B testing
* **Plus €179/month** — multi-provider email, full API + webhooks, priority support
* **Full Suite €399/month** — everything, white-label, dedicated SLA support

= What data does the plugin send to Flowgration? =

* **During Connect:** site URL, admin email, store name, WordPress/WooCommerce version, product/customer/order counts, category names, form names and field labels. No customer rows.
* **After Connect:** per-event payloads — `order.created`, `order.updated`, `customer.created/updated/deleted`, `cart.abandoned`, `product.*`, `subscription.*`, `booking.*`, `form.submitted`. Each payload contains only the fields the event needs.
* **Hourly:** a `plugin.heartbeat` with plugin version, queue depth, and last failure flag. No PII.

The plugin never sends API keys, passwords, full customer lists, file uploads, or any data you have not explicitly enabled in **Settings → Flowgration → Settings**.

= Is this GDPR-compliant? =

Yes. When a WordPress user is deleted, the plugin emits a `customer.deleted` event so Flowgration clears PII fields on the matching contact (preserving accounting references but blanking name and email). You can also disable any data category in the Settings tab to narrow the data flow at any time.

= Does this work without WooCommerce? =

Partially. The CRM auto-build and ecommerce sync features require WooCommerce. However, form capture (Gravity Forms, WPForms, Contact Form 7, and others) works on any WordPress site. WooCommerce 8.0+ is strongly recommended to unlock the full feature set.

= Can I pause syncing without disconnecting? =

Yes. Open **Settings → Flowgration → Settings** and uncheck any data categories you want to pause. New events are held in the local queue and resume sending when you re-enable. You can also pause the entire integration from the Flowgration dashboard.

= Will this slow down my WooCommerce checkout? =

No. All sync operations run asynchronously via a local event queue and WP background processing. Checkout and order processing are not blocked. Every WooCommerce hook handler is wrapped in a try/catch — a Flowgration outage cannot surface as an error on your checkout page.

= Does it work with managed WordPress hosts that disable WP-Cron? =

Yes. The plugin uses a multi-trigger drain stack (form-submit shutdown handler, admin-side JS poll, admin_init fallback, and a REST endpoint) so the event queue drains reliably even on Kinsta, WP Engine, SiteGround Optimizer, and other hosts that set `DISABLE_WP_CRON=true`.

= Something went wrong during setup — what do I do? =

Click **Disconnect** in the dashboard. This clears the local API key and tells Flowgration to detach the integration. Then click **Connect** again with the correct mode, email, or key. None of your existing Flowgration data is lost.

= Why did some events not arrive in my CRM? =

Open **Settings → Flowgration → Recent events** to see the last 50 events the backend received. If queue depth is high or "Failed in 24h" is non-zero, click **Test connection** — most issues are stale API keys or temporary network outages. The plugin retries with exponential backoff (immediate → 30s → 2 min → 10 min → 1 h) before giving up.

== Screenshots ==

1. Connection screen — choose "I'm new" for auto-build CRM, or "I already have an account" for connect mode.
2. Auto-build success — paste the API key shown on the Flowgration callback page.
3. Connect-mode field mapping — confirm AI-suggested mappings between your store and your CRM.
4. Connected dashboard — connection status, events sent today/month, queue depth, failed in 24 h, and action buttons.
5. Recent events table — the last 50 events as recorded by Flowgration's backend.
6. Settings tab — toggle individual event types and choose which forms to sync.
7. Backfill modal — choose 90 days / 12 months / everything and watch the live progress bar.

== Changelog ==

= 1.0.1 — 2026-06-30 =

* **WordPress.org review fixes.** Documented the Flowgration external service in the readme (new "External services" section) with the data sent, when, and Terms of Service + Privacy Policy links — including the WooCommerce REST API key pair sent during onboarding for the historical import. Corrected the Privacy section to match.
* **Hardened the public `/health` REST endpoint.** It now returns only non-sensitive liveness (ok/version, has_api_key boolean, backfill counts/status, error flag) — no integration id, store URL, API-key prefix, raw error text or connection status on the unauthenticated route.
* **No more inline admin `<script>`.** Moved the dashboard backfill progress-polling + auto-kick JavaScript out of an inline `<script>` and into the enqueued `admin/assets/admin.js` (passing the auto-kick flag via `wp_localize_script`).

= 1.0.0 — 2026-06-22 =

* **Listing polish + WordPress.org submission readiness.** Plugin Name, Tested up to, Requires at least, and Requires PHP headers aligned to the current supported stack (WP 6.0+, WC 8.0+, PHP 8.1+, tested on WP 7.0). Added WC requires/tested headers per WooCommerce HPOS compatibility declaration.
* **Forms capture, expanded.** Captures WooCommerce checkout + WP comments and adds Forminator, Bricks, WS Form, JetFormBuilder, HappyForms and MetForm alongside Gravity Forms, WPForms, CF7, Ninja, Elementor, Formidable, Fluent and SureForms — every submission flows into the CRM with field mapping. Fixed the abandoned-cart session sweep.
* **Field mapping = one source of truth.** The CRM owns the mapping; the plugin reflects it and now surfaces CRM-locked sources (no editing twice), caches the config, adds a global field-routing panel, a static "add tag on submit" action, and GDPR consent + UTM/attribution capture into the CRM.
* **i18n + WordPress.org compliance.** Text Domain set to `flowgration-crm` to match the plugin slug (fixes the Plugin Check Text-Domain-Mismatch errors). Language files renamed to `flowgration-crm-*`; admin JS strings now translatable via `wp.i18n`. Spanish (es_ES) included.
* **Security.** `esc_sql()` applied to WC API key table references in `Flowgration_WC_Keys`. JSON-decoded AJAX payloads routed through `sanitize_decoded_payload()` helper.

= 0.5.23 =

* **Internationalization (i18n) — English source strings, locale-driven translations.** All admin-page strings previously hardcoded in Spanish are now English source strings wrapped in WordPress gettext functions (`esc_html_e`, `esc_html__`, `__`). A Spanish translation is delivered via `languages/flowgration-es_ES.po` + `.mo`. The `Text Domain` plugin header is now `flowgration` (was `flowgration-crm`) and `load_plugin_textdomain` is called on `plugins_loaded`. Required change for WP.org directory listing.
* **Spanish copy on the "Import historical data" action tile replaced with English.** The Spanish description is now served via the es_ES translation file.

= 0.5.22 =

* **Field Mappings tab now shows real `fields_count` for every WooCommerce source card.** Canonical field-name tables per WC entity (35 order fields, 24 customer fields, 27 product fields, 18 coupon fields) replace the previous hard-coded `fields_count => 0`.
* **"0 fields detected" status line fixed.** `buildRows()` in `admin.js` now flattens the discovery TREE shape emitted by `Flowgration_Discovery::build_schema()` into editor rows with per-source tagging.
* **"Suggest with AI" now consumes `_suggest_mappings` response correctly.** Walks `contact_fields` and per-form `field_mapping` sub-trees so suggestions land on the rows.
* **Cache transient bumped to `flowgration_integrations_summary_v2`.** New payload shape ships with a fresh cache key; legacy v1 key is deleted on first v2 read.

= 0.5.21 =

* **Opt-in historical backfill on API-key reconnect.** Paste-existing-key flow no longer auto-imports into a CRM that already has data. A dedicated "Import historical data from WooCommerce" tile provides the opt-in affordance.

= 0.5.20 =

* **P0 persistence fix: per-WooCommerce-source Field Mappings page now hydrates from `mapping_config.sources[<bucket>]` on render.**
* **Custom field create: added `order` to the entity allow-list.**
* **Forensics: PII-safe breadcrumbs** added to `ajax_create_custom_field` and `render_per_woocommerce_source`.

= 0.5.18 =

* Plugin Check fix: `esc_sql()` added to `$table` assignment in `class-flowgration-wc-keys.php` lines 109, 195, 233.

= 0.5.17 =

* AI auto-mapping auto-fires on first visit to the Field Mappings tab (latched so manual un-maps are not reverted).
* New "Cart abandoned tracking" diagnostic card in the WP admin Diagnostic tab.

= 0.5.16 =

* **P0 ARCHITECTURE: WooCommerce REST API backfill.** Plugin now generates a read-only WC consumer key/secret pair at onboarding so the Flowgration backend can pull historical data via the WC REST API — WAF-proof, matching the Mailchimp/Klaviyo/HubSpot pattern.
* **New `Flowgration_WC_Keys` class** with idempotent generation and encrypted-at-rest storage.
* **Disconnect now revokes the WC keys** from `wp_woocommerce_api_keys`.
* **Plain-WP installs gracefully skipped** when WooCommerce is absent.

= 0.5.15 =

* Plugin Check fix: explicit `(int)` cast on `max(0, ...)` result in `dashboard-page.php` line 357.

= 0.5.14 =

* **P0 ARCHITECTURE: Plugin-initiated backfill drain (WAF-friendly).** New admin-ajax action `flowgration_admin_drain` plus admin_init fallback drain so no inbound WAF-blocked traffic from the backend is required after onboarding.
* **Dashboard UX: live progress widget** for historical import with real-time counter and progress bar.

= 0.5.13 =

* New PUBLIC REST endpoint `/wp-json/flowgration/v1/health` for backend diagnostics (no PII, no auth required).
* New HMAC-protected endpoint `/wp-json/flowgration/v1/echo-signed` for HMAC roundtrip diagnostics.
* All `wp_ajax_flowgration_*` handlers wrapped in `ob_start()` to strip pre-JSON noise from sibling plugins.
* `Flowgration_API_Key_Vault::store()` post-write assertion guards against silent write failures.

= 0.5.12 =

* `Flowgration_Backfill::start()` now runs the first chunk inline for hosts with `DISABLE_WP_CRON=true`.

= 0.5.11 =

* New REST endpoint `/wp-json/flowgration/v1/drain-backfill-chunk` for server-side backfill pumping without WP-Cron dependency.
* Discovery payload now includes `wp_cron_disabled` flag.

= 0.5.10 =

* New REST endpoint `/wp-json/flowgration/v1/disconnect` for HMAC-signed remote `org_deleted` signals.

= 0.5.9 =

* Backfill payload enrichment — `customer.created` backfill events now include full addresses, roles, and WC stats; `order.created` events include full line items, payment details, and addresses.

= 0.5.8 =

* Tested-up-to header updated. No code changes.

= 0.5.7 =

* New REST endpoint `/wp-json/flowgration/v1/kick-backfill` so the backend can trigger historical backfill immediately after magic-link activation.

= 0.5.6 =

* Security hardening for WP.org Plugin Review T2: raw `$_POST` reads moved after nonce/capability gates; new `sanitize_decoded_payload()` helper for JSON AJAX bodies.

= 0.5.5 =

* Auto-start full historical backfill on connect. `ajax_save_api_key` auto-discovers `integration_id`.

= 0.5.4 =

* WooCommerce order capture extended to all creation paths (`woocommerce_thankyou`, `woocommerce_new_order`, `woocommerce_checkout_order_processed`).
* Forminator forms captured out of the box.
* Every WooCommerce hook handler wrapped in try/catch.
* Outbound HMAC requests now carry `X-Flowgration-Timestamp` (Stripe-style replay protection).

= 0.5.3 =

* Compound form fields (Name, Address, Date/Time) split into sub-inputs in WPForms and Gravity Forms.

= 0.5.2 =

* Auto-drain redundancy stack: five independent triggers ensure queue drains within seconds even with `DISABLE_WP_CRON=true`.

= 0.5.1 =

* Hotfix: WPForms Lite submissions no longer collide as DEDUP. Content-addressed external IDs across all form adapters.

= 0.5.0 =

* Settings tab redesigned into seven grouped cards.
* Overview tab: 7-day sparklines, week-over-week deltas, Recent submissions card, Quick Actions grid.
* `_apply_mapping` now strips `contact.`/`opportunity.` prefixes and handles `contact.custom_fields.X` keys.
* New AJAX endpoints (capability-gated + nonce-protected): `flowgration_save_settings_v2`, `flowgration_reset_settings`, `flowgration_plugin_report`, `flowgration_recent_submissions`, `flowgration_sent_sparkline`.

= Older versions =

For changelog entries prior to 0.5.0 see `CHANGELOG_ARCHIVE.md` in the plugin source repository.

== Upgrade Notice ==

= 0.5.24 =

Header and listing update only. Requires PHP 8.1+ and WooCommerce 8.0+ going forward. No database changes, no logic changes. Safe to update.

= 0.2.0 =

Major upgrade. Adds connect mode, durable retry queue, backfill, full dashboard, and seven new runtime event types. Existing connections continue to work — you will see the new dashboard the next time you open Settings → Flowgration.

== External services ==

This plugin connects your site to **Flowgration**, the CRM and email-marketing service operated by Flowgration (https://flowgration.com). This connection is required for the plugin's core function: building and keeping your CRM in sync from your WooCommerce store. By default the plugin talks to `flowgration.com`; you can point it at a self-hosted backend from the plugin settings.

What data is sent, and when:

* **When you connect the plugin (onboarding):** your site URL, administrator email, store name, WordPress and WooCommerce versions, aggregate counts (products, customers, orders), category names and form names/field labels, and a **WooCommerce REST API key pair (consumer key + secret)** that the plugin generates so that Flowgration can perform a one-time historical import of your existing orders, customers and products. No customer rows are sent during onboarding itself.
* **On an ongoing basis (after connecting):** store event payloads as they happen — `order.*`, `customer.*`, `cart.abandoned`, `product.*`, `subscription.*`, `booking.*`, `form.submitted` — so your CRM stays up to date.
* **Hourly:** a heartbeat containing plugin/WordPress/WooCommerce versions and queue health (no personal data).

The plugin does **not** send your WordPress administrator password or any WordPress login credentials.

This service is provided by Flowgration. By connecting the plugin you agree to its Terms of Service and Privacy Policy:

* Terms of Service: https://flowgration.com/terms
* Privacy Policy: https://flowgration.com/privacy

== Privacy ==

The plugin sends the following data to the Flowgration backend (default: flowgration.com):

* **During Connect:** site URL, admin email, store name, WordPress/WooCommerce version, product/customer/order counts, category names, form names and field labels. No customer rows.
* **After Connect:** per-event payloads — `order.created`, `order.updated`, `customer.created/updated/deleted`, `cart.abandoned`, `product.*`, `subscription.*`, `booking.*`, `form.submitted`.
* **Hourly:** a `plugin.heartbeat` containing plugin version, WordPress/WC version, queue depth and last failure flag. No PII.

The plugin does not send your WordPress administrator password, WordPress login credentials, or files. It does generate and send a dedicated WooCommerce REST API key pair (consumer key + secret) during onboarding — used solely so Flowgration can run the one-time historical import; see the "External services" section above. The full payload specification is bundled with the plugin in `shared/SCHEMA.md` and `shared/RUNTIME_SYNC.md`, and also available at [flowgration.com/docs/plugins](https://flowgration.com/docs/plugins).
