=== Mailing Engineer ===
Contributors: mailingengineer
Tags: woocommerce, email marketing, abandoned cart, web push, automations
Requires at least: 6.3
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Connect your WooCommerce store to Mailing Engineer for email marketing, cart recovery, transactional order alerts, and Web Push automations.

== Description ==

**Mailing Engineer** is the official connector plugin for connecting your WordPress and WooCommerce store to the [Mailing Engineer](https://mailing-engineer.com/) email marketing, deliverability, and e-commerce automation platform.

The plugin is free and open-source (GPLv2 or later), imposes no artificial feature locks in plugin code, and makes **zero external connections** until a site administrator explicitly connects their Mailing Engineer account in **Settings -> Mailing Engineer**.

= Key Features =

* **Full WooCommerce HPOS & Checkout Blocks Compatibility** — Declares native compatibility with High-Performance Order Storage (`custom_order_tables`) and Cart & Checkout Blocks (`cart_checkout_blocks`).
* **Real-Time E-Commerce Automation Webhooks (HMAC-SHA256 Signed)** — Automatically notifies your Mailing Engineer workflows on add-to-cart, checkout started, order created (Classic Checkout, Blocks Checkout, and Admin/REST orders), order fulfilled with courier AWB tracking details, order cancelled, order refunded, and coupon updates.
* **Unlimited Cursor-Paginated Store Sync** — Efficiently syncs active in-stock products (including variable product sale prices, SKUs, and categories), WooCommerce coupons, customers, and orders without memory spikes.
* **Courier Tracking & AWB Support** — Reads tracking numbers and providers from WooCommerce Shipment Tracking and popular European/Romanian courier plugins (Sameday, FAN Courier, Cargus, GLS, DPD, Bookurier, Innoship, ColeteOnline, CurieRO) for automated shipping notifications.
* **Checkout Marketing Opt-In Checkbox** — Optional, customizable checkout opt-in checkbox that records the customer's marketing preference (`_mailing_engineer_marketing_optin`) per order. Store owners remain responsible for their own privacy and legal notices.
* **Web Push Notifications (RFC 8292 VAPID)** — Optional self-contained static Service Worker (`assets/js/mailing-engineer-sw.js`) for browser push notifications with zero remote `importScripts()` calls.
* **Magic Cart & Auto-Coupon Recovery Links** — Nonce-protected cart recovery and coupon confirmation prompt (`?mailing_engineer_cart=id:qty`, `?mailing_engineer_coupon=CODE`) when shoppers return from email or push campaigns.
* **Google Merchant / Product XML Feed** — Built-in native WordPress XML product feed (`/?feed=mailing-engineer-products`) available once connected.
* **Optional Form & Newsletter Plugin Sync** — Opt-in setting (disabled by default) to include existing subscribers from Elementor Forms, MailPoet, The Newsletter Plugin, FluentCRM, Contact Form 7 / Flamingo, WPForms, and Hustle.
* **Clean Uninstall & Privacy First** — Zero front-end "Powered by" branding links, zero background calls before setup, and complete option cleanup via `uninstall.php`.

== External services ==

This plugin connects your WordPress / WooCommerce site to the **Mailing Engineer** Software-as-a-Service (SaaS) platform, operated by **BSNS AGENCY ONLINE S.R.L.**, to power email campaigns, transactional notifications, abandoned cart recovery, analytics, and Web Push automations.

No data is transmitted and no external scripts are loaded until a site administrator explicitly saves their Mailing Engineer **Pixel Key** and **Webhook Secret** in **Settings -> Mailing Engineer**.

Once connected, the plugin communicates with the following endpoints (either on `https://mailing-engineer.com` or on the store owner's verified custom tracking subdomain `https://nl.<yourdomain>`):

1. **Storefront Pixel SDK (`https://mailing-engineer.com/sdk/me-pixel.js`)**
   * **What is sent:** The store's public Pixel Key, anonymous first-party session identifier (`me_sid`), page URL, viewed product metadata, and (when a visitor is logged in or explicitly submits an email at checkout/newsletter form) the visitor's email address.
   * **When:** Loaded on public storefront pages via `wp_enqueue_script()` only after the merchant connects their account and enables storefront tracking or Web Push.
   * **Why:** Enables abandoned cart identification, browse abandonment, attribution, and opt-in Web Push prompts.

2. **Signed Event & Webhook Ingestion API (`https://mailing-engineer.com/api/saas/push/event`)**
   * **What is sent:** HMAC-SHA256 signed JSON payloads for WooCommerce events (`store_snapshot`, `add_to_cart`, `checkout_started`, `product_viewed`, `order_created`, `order_fulfilled`, `order_cancelled`, `order_refunded`, `coupon_updated`, and `welcome_subscriber`), containing order totals, line items, coupon codes, shipping AWB tracking numbers, and customer billing details (name, email, phone, city, marketing opt-in status).
   * **When:** Triggered server-to-server when corresponding WooCommerce events occur or when an administrator clicks **Sync Store Now**.
   * **Why:** Triggers transactional emails, abandoned cart reminders, post-purchase flows, and revenue attribution inside the merchant's Mailing Engineer account.

3. **Web Push Service Worker Telemetry (`https://mailing-engineer.com/api/saas/push/delivered`, `/api/saas/push/click`, `/api/saas/push/latest`)**
   * **What is sent:** Campaign/event ID, signed click token, push subscription token, and public Pixel Key.
   * **When:** Only when Web Push is enabled in Settings and a browser subscriber receives or clicks a push notification.
   * **Why:** Records push notification delivery and click metrics and opens the target store URL.

4. **Mailing Engineer Portal (`https://portal.mailing-engineer.com`)**
   * **What is sent:** When the administrator clicks **Connect with Mailing Engineer** in WP Admin, the browser navigates to the Mailing Engineer Portal with the store's domain query parameter so the merchant can sign in and authorize 1-Click WooCommerce API access or retrieve their Pixel Key and Webhook Secret.
   * **Why:** Account onboarding and credential retrieval.

= Legal & Privacy Links =

* Service provider: **BSNS AGENCY ONLINE S.R.L.**
* Terms of Service: [https://mailing-engineer.com/terms](https://mailing-engineer.com/terms)
* Privacy Policy: [https://mailing-engineer.com/privacy](https://mailing-engineer.com/privacy)
* Data Processing Agreement (DPA): [https://mailing-engineer.com/dpa](https://mailing-engineer.com/dpa)

== Installation ==

1. Install **Mailing Engineer** from **Plugins -> Add New** in your WordPress Admin (or upload `mailing-engineer.zip`).
2. Activate the plugin. No external connections are made until you configure your account.
3. Go to **Settings -> Mailing Engineer**.
4. Click **Connect with Mailing Engineer** to log in or create your account at [portal.mailing-engineer.com](https://portal.mailing-engineer.com/), connect your WooCommerce store, and copy your **Pixel Key** and **Webhook Secret**.
5. Paste your **Pixel Key** and **Webhook Secret** into **Settings -> Mailing Engineer**, review your optional feature toggles (Web Push, checkout marketing opt-in checkbox, third-party form sync), and click **Save Settings**.
6. Click **Sync Store Now** to send an initial catalog and order snapshot.

== Frequently Asked Questions ==

= Does this plugin require a Mailing Engineer account? =

Yes. Mailing Engineer is an external email marketing and automation platform. You can create an account at [portal.mailing-engineer.com](https://portal.mailing-engineer.com/) and connect your store in under two minutes.

= Does the plugin send data automatically upon activation? =

No. On installation and activation, the plugin remains completely idle and sends zero external requests until an administrator enters and saves a valid Pixel Key and Webhook Secret in **Settings -> Mailing Engineer**.

= Is this plugin compatible with WooCommerce HPOS and Checkout Blocks? =

Yes. Mailing Engineer declares official compatibility with both WooCommerce High-Performance Order Storage (`custom_order_tables`) and Cart & Checkout Blocks (`cart_checkout_blocks`), and hooks into both classic checkout (`woocommerce_checkout_order_processed`) and Store API blocks checkout (`woocommerce_store_api_checkout_order_processed`).

= Does the plugin add any "Powered by" links to my storefront? =

No. The plugin never inserts promotional links, badges, or attribution footers on your public website.

= How does the Web Push Service Worker work? =

When Web Push is enabled in Settings, the plugin registers its bundled, self-contained static Service Worker (`assets/js/mailing-engineer-sw.js`) using standard RFC 8292 VAPID Web Push APIs. It never loads remote executable scripts inside the Service Worker.

= What happens when I delete the plugin? =

Deleting the plugin from WordPress Admin runs `uninstall.php`, which cleanly removes all `mailing_engineer_*` options from your database.

== Screenshots ==

1. Clean connection, credential setup, and privacy/feature toggle screen in WordPress Admin (Settings -> Mailing Engineer).

== Changelog ==

= 1.0.0 =
* Initial release for the WordPress.org Plugin Directory.
* Full WooCommerce HPOS (`custom_order_tables`) and Cart & Checkout Blocks (`cart_checkout_blocks`) compatibility.
* Deduplicated order webhooks across Classic Checkout, Checkout Blocks Store API, and Admin/REST orders.
* Cursor-paginated product, order, and customer sync endpoints signed with HMAC-SHA256 via WordPress REST API (`mailing-engineer/v1`) and native XML product feed (`/?feed=mailing-engineer-products`).
* Local storefront tracker (`assets/js/storefront-tracker.js`) and self-contained VAPID Web Push Service Worker (`assets/js/mailing-engineer-sw.js`).
* Customizable checkout marketing opt-in checkbox and opt-in third-party form sync toggle.
* Clean uninstall handler (`uninstall.php`).

== Upgrade Notice ==

= 1.0.0 =
Initial public release of the official Mailing Engineer connector for WordPress and WooCommerce.
