=== CartCue – Abandoned Cart Recovery & Sales Automation for WooCommerce ===
Contributors:      userelements
Tags:              abandoned cart, cart recovery, woocommerce, woocommerce email, win back
Requires at least: 6.2
Tested up to:      7.0
Requires PHP:      7.4
Stable tag:        1.0.12
License:           GPLv2 or later
License URI:       https://www.gnu.org/licenses/gpl-2.0.html
WC requires at least: 8.0
WC tested up to:   9.9

WooCommerce win-back campaigns and abandoned cart recovery with unique coupons and safe batch sending. No monthly SaaS fee.

== Description ==

**CartCue** helps WooCommerce stores recover revenue from lapsed customers and abandoned carts, entirely inside WordPress. No monthly SaaS fee, no customer data leaving your server.

Most stores lose sales in two predictable places: shoppers who abandon checkout, and buyers who have not ordered in months. CartCue gives you both automated recovery and controlled win-back campaigns so you can win those customers back with personalised emails and WooCommerce coupons.

= Win back lapsed customers (Pro) =

CartCue Pro includes **Campaigns** - manual win-back campaigns you launch on your schedule:

* Target customers who have not ordered in 90, 120, or any number of days
* Generate a **unique WooCommerce coupon** per customer
* Reach **registered buyers and imported guest customers** in one segment
* **Send in batches** (50, 100, …) so you can monitor deliverability and results
* **Test on your own email** before sending to customers
* Track **recovered revenue** per campaign

Use the built-in **Win-back coupon campaign** template to get started in minutes.

= Abandoned cart recovery (Free) =

CartCue detects when a shopper enters their email at checkout and leaves before completing the order. It waits your chosen delay (10 minutes, 1 hour, or 1 day) and sends a personalised recovery email with cart contents, total, and a direct recovery link. You can include a coupon to bring them back.

Works for registered customers and guest shoppers. No external account needed.

= WooCommerce automation without the complexity =

Every automation follows a plain-English flow:

1. **Trigger:** what WooCommerce event starts this?
2. **Timing:** how long to wait?
3. **Conditions:** who qualifies?
4. **Action:** send email, generate coupon, add order note, or change order status.

No drag-and-drop canvas or 40-tab wizard. Most stores are running in under 5 minutes.

= Automation triggers included free =

* **Cart Abandoned** - recover carts from shoppers who entered their email and left
* **Checkout Started** - catch shoppers who reached checkout but did not finish
* **Order Paid** - post-purchase follow-ups, thank-you emails, review requests
* **Order Status Changed** - trigger when orders move between WooCommerce statuses
* **Payment Failed** - recovery reminder when payment fails
* **Order Refunded / Cancelled** - follow up after refunds or cancellations
* **New Customer Created** - welcome new registered customers
* **Customer Win-Back** - daily automated re-engagement for inactive customers
* **Never Purchased** - nudge registered users who signed up but never bought

= Personalized WooCommerce emails =

Built-in variables for customer name, order details, cart contents, coupon codes, store name, and recovery links. Sent through `wp_mail()`. Compatible with WP Mail SMTP, Post SMTP, and any SMTP plugin.

Variable fallbacks prevent awkward blanks: `{{customer.first_name|there}}` outputs "there" when a guest has no stored name.

= Audience conditions =

* Order total above or below a threshold
* Customer placing their first order
* Customer has ordered N or more times
* Days since last paid order
* Customer is registered or guest
* Customer has a specific WordPress role

= Ready-made templates =

* Abandoned cart recovery (1-email and escalating sequences)
* **Win-back coupon campaign** (Pro - manual batches with unique coupons)
* Post-purchase review request
* Automated win-back for inactive customers
* Welcome email with coupon for new customers
* Failed payment recovery

= Reports and email tracking =

* Email open rate and click rate per automation
* Revenue attributed to each play (Pro)
* Activity log with success, skipped, and error status
* Execution history per customer

= Why CartCue instead of a marketing SaaS? =

Most abandoned cart and email tools are monthly subscriptions that send customer data to external servers. CartCue stores everything in your WordPress database.

**CartCue Pro is a one-time purchase per site**, not a monthly fee that scales with your revenue.

= WooCommerce compatibility =

* WooCommerce High-Performance Order Storage (HPOS) compatible
* Works with WooCommerce Blocks checkout (for consent)
* Compatible with any SMTP or transactional email plugin
* Supports WooCommerce multi-currency

= Free plan limits =

* Up to 5 active automation plays at a time
* 2 timed follow-up steps per play
* All free triggers and actions listed above
* Reports, email tracking, and recipe templates included

= CartCue Pro =

[CartCue Pro](https://www.userelements.com/cartcue-woocommerce-automation/?utm_source=plugin&utm_medium=readme&utm_campaign=upgrade) adds campaign mode and advanced automations for growing stores:

**Campaigns (hero feature):**
* Manual win-back campaigns with unique coupon per customer
* Staged batch sending (50, 100, …) with test-email mode
* Registered + imported guest segments (deduplicated)
* Revenue attribution per campaign

**Additional Pro triggers:**
* New Product Review
* Low Stock Alert
* Customer Birthday
* WooCommerce Subscriptions (renewal, cancellation, pause, reactivation)
* Manual Campaigns (send to a custom segment on demand)

**Additional Pro actions:**
* Unique coupon generation per customer
* SMS notifications via Twilio or Vonage
* CRM sync - FluentCRM, Mailchimp, MailPoet, ActiveCampaign, Klaviyo
* Outgoing webhooks (Zapier, n8n, Make)
* Slack notification, trigger another play, change customer role, loyalty points

**Pro also includes:**
* Unlimited follow-up sequence steps
* Revenue attribution per play
* CSV export of logs and customer data
* Play import / export (JSON)

= Learn more =

* [How to win back inactive WooCommerce customers](https://www.userelements.com/win-back-inactive-woocommerce-customers/?utm_source=plugin&utm_medium=readme&utm_campaign=resources)
* [How to automatically ask for a product review](https://www.userelements.com/woocommerce-review-request-automation/?utm_source=plugin&utm_medium=readme&utm_campaign=resources)
* [How to send WooCommerce order status update emails](https://www.userelements.com/woocommerce-order-status-update-emails/?utm_source=plugin&utm_medium=readme&utm_campaign=resources)
* [Introducing CartCue Pro](https://www.userelements.com/introducing-cartcue-woocommerce-sales-automation/?utm_source=plugin&utm_medium=readme&utm_campaign=resources)
* [Best WooCommerce automation plugins compared](https://www.userelements.com/list/best-woocommerce-automation-plugins/?utm_source=plugin&utm_medium=readme&utm_campaign=resources)

Pro tutorials:

* [Automatic birthday coupons in WooCommerce](https://www.userelements.com/woocommerce-birthday-coupon-automation/?utm_source=plugin&utm_medium=readme&utm_campaign=resources_pro)
* [Reward your top WooCommerce customers automatically](https://www.userelements.com/reward-vip-customers-woocommerce/?utm_source=plugin&utm_medium=readme&utm_campaign=resources_pro)
* [Sync WooCommerce customers to Mailchimp, FluentCRM, or Klaviyo](https://www.userelements.com/woocommerce-crm-sync-mailchimp-fluentcrm-klaviyo/?utm_source=plugin&utm_medium=readme&utm_campaign=resources_pro)

== Installation ==

1. In your WordPress dashboard, go to **Plugins → Add New** and search for "CartCue".
2. Click **Install Now**, then **Activate**.
3. Go to **CartCue** in the admin sidebar.
4. Click **Browse Recipes** to pick a ready-made automation - or **Build from Scratch** to start fresh.
5. Activate your play.

**Recommended first automation:** The Abandoned Cart Recovery recipe. It runs hands-free once activated and is the fastest path to recovered revenue for most WooCommerce stores.

== Frequently Asked Questions ==

= What is CartCue? =

CartCue is a WooCommerce abandoned cart recovery and sales automation plugin. It lets you create automated plays triggered by WooCommerce events - abandoned carts, paid orders, failed payments, new customers, inactive customers, and more - and takes actions like sending a personalized email, generating a coupon, or changing an order status.

= How does WooCommerce abandoned cart recovery work? =

When a shopper enters their email address at checkout and leaves before completing the order, CartCue captures the cart and schedules a recovery email. You can send the email immediately or after a delay (e.g., 1 hour, 24 hours). The email includes the cart contents, total, and a one-click recovery link that restores their cart automatically.

= Does abandoned cart recovery work for guests? =

Yes. CartCue recovers guest carts as long as the shopper has entered their email address at checkout. You can also configure plays to send only to registered customers if you prefer.

= Does CartCue require a monthly subscription? =

No. The free version is fully functional with no subscription or credit card required. CartCue Pro is a per-site purchase, not a monthly recurring fee that scales with your revenue or contact count.

= Will CartCue work with my SMTP or transactional email plugin? =

Yes. CartCue sends email through `wp_mail()`, the standard WordPress email function. It is compatible with WP Mail SMTP, Postmark, Mailgun, SendGrid, FluentSMTP, and any other SMTP or transactional email plugin.

= Is CartCue compatible with WooCommerce HPOS? =

Yes. CartCue is fully compatible with WooCommerce High-Performance Order Storage (HPOS / custom order tables).

= Can I send personalized WooCommerce emails with customer and order data? =

Yes. CartCue emails support variables for customer first name, last name, email, order number, order total, order items, product review URL (`{{order.review_url}}`), cart total, cart recovery link, coupon code, store name, and store URL. You can use fallback values for missing data - for example `{{customer.first_name|there}}` outputs "there" for guests with no stored name.

= Can I create and send coupon codes automatically? =

Yes. The free version includes a Create Coupon action that creates a coupon with your chosen discount and inserts it into the email. For a unique, one-time coupon code generated per customer, upgrade to CartCue Pro.

= How is CartCue different from FunnelKit Automations or AutomateWoo? =

CartCue is lighter, faster to set up, and does not require an external CRM account or a monthly subscription. It is focused on WooCommerce-native automations that store owners need most: abandoned cart recovery, win-back, post-purchase follow-ups, and payment recovery. Advanced marketing CRM features are not included by design.

= Can I build a follow-up sequence - multiple emails over several days? =

Yes. Each CartCue play supports follow-up steps with individual time delays. The free version includes up to 2 follow-up steps per play. CartCue Pro supports unlimited steps.

= Does CartCue track email opens and clicks? =

Yes. CartCue embeds a tracking pixel for opens and wraps links for click tracking. Open rate, click rate, and per-play performance are visible in the Reports dashboard.

= Can I use CartCue to send win-back emails to inactive customers? =

Yes. The free **Customer Win-Back** trigger runs daily for customers who have not placed a paid order in a set number of days. For controlled batch campaigns with a unique coupon per customer - send 50 at a time, test on your own email first - upgrade to **CartCue Pro Campaigns** and use the Win-back coupon campaign template.

= Does CartCue store customer data on my server? =

Yes. All automation logs, cart data, email tracking, and customer consent records are stored in your WordPress database. No customer data is sent to CartCue or any external server.

= Is CartCue compatible with WooCommerce Subscriptions? =

The free version works with standard WooCommerce orders. CartCue Pro adds dedicated triggers for WooCommerce Subscriptions renewal, cancellation, pause, and reactivation events.

= Can I export activity logs or customer data? =

Log export (CSV) is available in CartCue Pro. The free version provides in-dashboard reporting with the activity log view.

= What WooCommerce version does CartCue require? =

CartCue requires WooCommerce 8.0 or higher. It has been tested up to WooCommerce 9.9.

== Screenshots ==

1. **Active plays dashboard** - see all live automations with status, run count, and last activity at a glance.
2. **Abandoned cart recovery play** - the abandoned cart recipe pre-configured and ready to activate.
3. **Play builder (wizard)** - build automations in a guided 4-step flow: trigger, timing, email, and review.
4. **Trigger selection** - choose from 10 free WooCommerce triggers including cart abandoned, order paid, win-back, and more.
5. **Email builder** - write personalized emails using a visual block editor with variable chips and live preview.


== Changelog ==

= 1.0.12 =
* New: {{order.review_url}} merge tag — links to the WooCommerce reviews section for the first product in the order (also {{order.product_url}} and {{order.review_links}} for multi-product orders).
* Improved: Button Link URL personalization now includes Order tags (review_url, product_url, etc.), not only Cart and Shop.
* Improved: Ask for a review template uses {{order.review_url}} instead of the shop homepage.

= 1.0.11 =
* Fixed: Global Styles brand/header color now applies to the purple header bar on sent emails and test emails (previously only the builder preview used it).
* Improved: Global Styles label renamed to "Brand / header color" to make the setting clearer.

= 1.0.10 =
* Fixed: Contacts page now includes registered WooCommerce customers (WP_User_Query fields returned stdClass objects that were skipped).
* Fixed: Paid order status queries no longer use array_keys(wc_get_is_paid_statuses()), which produced numeric indexes instead of status slugs.
* Fixed: Product, category, and tag purchase triggers now fire only the matching automation instead of every workflow on that trigger.
* Fixed: Customer Has Never Purchased and Win-Back daily jobs paginate past already-contacted or ineligible customers.
* Fixed: Campaign "purchased" / "never purchased" segments use paid order statuses; inactive 30/60-day segments query last paid order dates instead of missing _wc_last_order_date meta.
* Fixed: Plugin deactivation and uninstall unschedules all CartCue Action Scheduler hooks (including jobs with arguments).
* Fixed: Condition rules fail closed when required context or configuration is missing.
* Improved: Contacts table is horizontally scrollable and uses a stacked card layout on narrow screens.

= 1.0.9 =
* New: Win-back coupon campaign template (Pro) - preview on Templates → Campaigns; manual trigger with unique coupon + email and Days Since Last Order > 120 rule.
* New: Campaigns admin menu item with Pro upsell page explaining win-back batch campaigns, unique coupons, and guest + registered segments.
* New: Contacts admin page - search marketing contacts (registered + guests), add addresses, and manually unsubscribe or reactivate. Suppression survives guest re-import and does not affect WooCommerce transactional emails.
* Improved: Admin menu reordered - Campaigns second (Automations → Campaigns → Reports → Templates → Settings).
* Improved: Templates tab renamed One-time blast → Campaigns; campaign templates filtered to manual-trigger recipes with featured win-back quick-start.
* Improved: New automation type picker uses Campaign wording with win-back example; Pro template cards show a Pro badge when applicable.
* Improved: WordPress.org description rewritten - leads with win-back campaigns and abandoned cart recovery instead of generic autopilot copy.
* Improved: Plugin header description updated to match.
* Improved: Customer unsubscribe and admin suppress also clear registered-user consent meta for consistent status.
* Improved: Reports → Unsubscribe Reasons links to Contacts for manual management.

= 1.0.8 =
* Improved: Send Now segment preview shows eligible count when an automation is selected (e.g. "120 in segment, 45 eligible for this automation, 20 will be sent (limit)") (Pro).
* Fixed: Send Now Limit now counts recipients who pass automation rules and frequency guards (not just the first N raw segment candidates) - staged batches (e.g. 50 or 100 at a time) send the requested number when enough eligible customers exist, and repeated runs advance to the next eligible recipients instead of re-scanning the same raw slice (Pro).
* Fixed: "All registered customers" segment no longer includes administrator accounts (aligned with Role: Customer segment).

= 1.0.7 =
* Fixed: "Wait before this step" values now persist correctly - the unified editor no longer overwrites saved per-action delays with hardcoded defaults on page load.
* Fixed: "Send test" button now fires the test AJAX request - `apCollectInlineActions` is exposed globally and the email builder syncs before collecting inline actions for the test payload.
* Fixed: shared coupon action now uses slug `create_shared_coupon`, separate from the Pro unique-coupon action (`create_coupon`), preventing schema collisions when license state changes; legacy saves with `create_coupon` still resolve correctly.
* Fixed: plain-text email bodies no longer apply a redundant `wp_unslash()` that could strip intentional backslashes.
* Fixed: Send Now segment preview count now respects the Limit field and shows "X matching, Y will be sent" when a cap applies (Pro).
* Fixed: "Days Since Last Order" rule now counts only paid orders for registered customers, matching the guest billing-email lookup.
* Fixed: email click-tracking links (`/cartcue-track/click/`) returning 404 when rewrite rules were stale after install or update - rules now register before flush on activation, auto-flush on frontend loads via a versioned option, and a URI fallback handler records clicks even before rewrites refresh.
* Fixed: historical guest import and consent migration could overwrite a previous unsubscribe (`status = 0`) back to opted-in - `grant()` now blocks historical/migration sources from resurrecting suppressed addresses; checkout opt-in can still restore consent.
* Fixed: duplicate `id="ap-test-btn"` in the unified play editor - header and live-preview send buttons no longer collide; test-send handlers use a shared class.
* Fixed: loading an email preset in the visual builder no longer throws a `renderStylesPanel` reference error.
* Fixed: plays list overflow (⋯) menu now toggles closed on a second click instead of immediately reopening.
* Fixed: unified play editor no longer runs competing audience-count requests from `admin.js` and `audience-estimate.js` on the same container.
* Fixed: unified play editor timing and frequency pill clicks no longer fire duplicate handlers from legacy `admin.js` bindings.
* Improved: Send Now success message clarifies that automation rules are evaluated when the queued run executes (Pro).
* New: "Customer email" automation rule - equals, contains, or does not equal.
* New: Send Now - optional "Send only to these test emails" field to queue a campaign only to specified addresses within the selected segment (Pro).

= 1.0.6 =
* New: Settings → SMS & WhatsApp tab - configure Twilio and Vonage credentials (Pro required to send; credentials can be saved on Free). Auth tokens/secrets are preserved when left blank on save.
* New: SMS test delivery on the SMS settings tab - verify Twilio or Vonage credentials with a test message.
* New: Custom email wrapper in Settings → Advanced - optional HTML shell with {{BODY}} for all CartCue outbound emails.
* Improved: Customer Win-Back trigger finds all customers inactive at least N days (not just a ±12h window), skips those already recorded in play_runs for the workflow, and supports batch limits via filter.
* Improved: Reports overview - clearer revenue labelling, stat card sublabels, open-rate empty state, chart polish, and per-play links; CSV export button links to Pro upgrade on Free.
* Improved: Reports → Activity Log - compact filter toolbar and fixed-width date inputs.
* Improved: Settings layout - tab navigation (General, SMS & WhatsApp), grouped compliance fields, and consistent input sizing; removed dead ?tab=integrations and ?tab=advanced routes.
* Fixed: Reports tab header no longer shows a vertical scrollbar on narrow layouts.
* Fixed: visual email builder now persists sidebar edits (text, button, colours) to the hidden body field - `updateBlockPreview()` was targeting the removed card layout and skipped `persist()` on most edits.
* Fixed: builder sync runs in the submit capture phase and on submit-button click so the latest canvas state is posted even when other handlers run first.
* Fixed: email body save no longer double-applies `wp_unslash()` after the actions array is already unslashed; corrupted builder JSON now shows an admin error instead of silently saving empty content.

= 1.0.5 =
* Fixed: fatal error when saving or activating automations (missing SequenceBuilder and PlayLabels imports in the admin save handler).
* Fixed: one-time blast (manual campaign) now sets and saves Manual / Campaign correctly when CartCue Pro is active - dedicated editor UI, hidden trigger input, and server-side enforcement.
* Fixed: audience preview for one-time blasts includes registered customers and imported guest emails; audience filter changes update the match count (Pro).
* Guest import: campaign segment layer recognizes imported guest emails (Pro).
* UX: "New automation" opens the type picker (Triggered vs One-time blast) instead of jumping straight to Templates.
* Fixed: manual campaign editor fatal error (missing play-edit.php) - campaigns now use the unified play editor.
* Fixed: database errors for missing ap_carts triggered_at and lost_at columns on existing installs (schema upgrade runs on every load).
* Play editor: styled “See all tags” expand control to match CartCue buttons.
* Settings: Save settings button now uses the same CartCue primary button style as the rest of the admin.
* New: block (Store API) checkout now captures guest emails for Cart Abandoned and Checkout Started recovery - previously only the classic shortcode checkout was supported. Capture runs server-side and respects the cart-tracking consent setting.
* Fixed: minimum cart total and cart-total trigger conditions now use a precise numeric amount, fixing incorrect matching on stores that use comma decimals or thousands separators.
* Fixed: completing an order after reaching checkout now cancels the queued "you didn't finish checkout" follow-up (carts in the checkout-started state are marked purchased).
* Improved: revenue attribution no longer credits transactional emails (order paid, payment failed, status change, refund/cancel, review request) and requires an open or click by default (Pro). New filters: cartcue_non_attributable_triggers and cartcue_attribution_require_engagement.
* Fixed: multi-step manual campaign sequences no longer default to a 1-day delay between steps - subsequent steps run immediately unless a delay is explicitly configured.
* Fixed: "Days Since Last Order" audience filter now checks the customer's billing email in addition to their customer ID, so orders placed as a guest before registering are counted correctly.
* Fixed: email body content in the visual builder is now reliably included on save - the builder syncs its canvas state to the hidden textarea immediately before the form is posted.
* Fixed: TinyMCE no longer initialises on email-builder-controlled textareas, preventing raw builder JSON from appearing in the classic editor fallback.
* Fixed: "Send test" emails now bypass marketing-consent and unsubscribe checks so the admin address always receives the test message.
* Fixed: "Send test" now uses the live editor content rather than the last-saved database state, so unsaved changes are reflected in the test send.
* New: "All eligible customers - registered + imported guests" campaign segment combines and deduplicates registered customers and imported guest contacts by email address (registered account takes priority when the same email appears in both groups).

= 1.0.4 =
* Unified play editor: multi-step follow-ups now save correctly with per-action wait fields (fixes recipes losing sequence timing on save).
* Unified editor: trigger search, conditional trigger settings (description + show/hide dependencies), and categorized action inserter groups.
* Removed legacy play editor and unused stepper/timeline assets; all event automations use the unified editor.
* Play labels: comma-separated tags in Advanced settings, label chips on the automations list, and label filter in the toolbar.
* Cart abandoned trigger: priority field (one play per cart when multiple match) plus minimum cart total and required product ID filters with quick preset chips.
* Extended initial wait modes: send at a specific store time (optional weekdays) or until a chosen date/time.
* Reports: per-play report page with step performance chart and recent customer activity; Steps link in the performance table.
* Reports overview: “Revenue recovered” hero stat with watching-state copy when attribution is still $0.
* Automations list: in-progress badge for plays with pending scheduled follow-up jobs; live status strip (carts seen today, recovery emails queued, recovered today).
* Performance: WooCommerce trigger hooks register only for triggers used by active plays (cart tracking always stays on).
* Onboarding: first-run wizard collapsed to one screen - pick a goal and activate in a single click.
* Empty state & templates: one-click “Turn on Abandoned Cart Recovery” creates, activates, and opens the play report.
* Templates: 8 featured recipes up front; remaining templates under a collapsed “More templates” section.
* Free admin menu streamlined - Send Now and Integrations removed (upsell rows on Templates and Settings instead).
* Free editor: Pro ghost inserter curated to 5 high-intent teasers (SMS, CRM sync, Subscriptions, Birthday, Webhook).
* Settings: global limits, quiet hours, non-production safety, and guest import moved into a closed Advanced accordion; JSON import is Pro-only.
* Settings: deliverability pre-flight - “Sending as …” with inline send test next to From email.
* Review prompt: one-time wp.org review ask after the first real email send or recovered order (dismissible).
* Metadata: keyword-rich plugin title, tags, and short description for WordPress.org search.
* Requires WooCommerce 8.0 or higher (tested up to 9.9).

= 1.0.3 =
* Release

= 1.0.2 =
* Free plan: up to 5 active plays at a time (unlimited paused plays); Pro has unlimited active plays.
* Merged execution logs into Reports (Overview and Logs tabs); the legacy Logs menu URL now redirects automatically.
* Added guided 4-step wizard for new plays: Trigger → Timing → Message → Review.
* Added variable fallback syntax: `{{customer.first_name|there}}` outputs fallback when variable is empty.
* Added frequency limit pill controls (every time / once per customer / cooldown period).
* Improved story bar: clicking any colored step jumps directly to that section.

= 1.0.1 =
* Fixed plugin name collision on activation.

= 1.0.0 =
* Initial release - WooCommerce abandoned cart recovery, win-back emails, post-purchase automations, coupon generation, email tracking, and reports.