=== CatCode Dotdigital Sync for WooCommerce ===
Contributors: catcodestudio
Tags: dotdigital, newsletter, email marketing, woocommerce, gdpr
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Newsletter sign-up at the WooCommerce checkout straight into your Dotdigital list, with a consent record for every buyer who ticks the box.

== Description ==

Adds an unticked "Email me news and offers" checkbox to the WooCommerce checkout. A buyer who ticks it is added to the Dotdigital list you choose, subscribed to e-mail, with a consent record. Buyers who leave the box empty are not sent to Dotdigital.

* **Classic and block checkout** — the checkbox sits above the "Place order" button on the classic checkout and in the order section of the block checkout. It is never ticked in advance.
* **Consent record** — the text the buyer saw, the time, the checkout page, the IP address and the browser go to Dotdigital with the contact, as UK GDPR and PECR ask you to be able to show.
* **Single or double opt-in** — with double opt-in Dotdigital e-mails new contacts a link to confirm their subscription.
* **Returning subscribers handled** — someone who unsubscribed earlier and ticks the box again gets Dotdigital's own resubscription e-mail; an address Dotdigital suppresses (hard bounce, complaint) is left alone and the order note says why.
* **Your list, your text** — load the lists of your account with one click, pick one, and edit the checkbox text.
* **Region found for you** — "Check connection" asks Dotdigital which region (Europe, North America, Asia Pacific) your account lives in.
* **Runs in the background, once per order** — the checkout never waits for Dotdigital. A call that could not get through (no answer, rate limit, server error) is retried once; a refusal is written to the order notes with Dotdigital's reason.
* **Order box** — every order shows whether the buyer signed up and what Dotdigital answered.
* HPOS and block checkout compatible. The API password is stored encrypted.

= Pro =

The Pro version is sold on [catcode.com.ua](https://catcode.com.ua/modules/catcode-dotdigital-sync-for-woocommerce/), with a 7-day trial that never starts by itself:

* **Orders in Dotdigital** — orders go to the "orders" Insight data collection of the buyer in the standard Dotdigital order schema (total, currency, date, products with SKU, price and quantity, coupon, addresses), for product recommendations, ecommerce analytics and segments. Processing, completed, cancelled and refunded update the same record; you choose the statuses.
* **No accidental subscriptions** — Dotdigital subscribes a new contact by default, so the plugin sends orders only for buyers who ticked the box or are already contacts. Optionally it adds the others as contacts with the status "unsubscribed".
* **Customer totals for segments** — contact data fields with the number of orders, total spent, date, total and status of the last order; one button creates the fields in your account.
* **Product catalogue** — a catalog_ collection with name, price, sale price, price incl. VAT, SKU, URL, image, stock and categories, updated when a product is saved and removed when it is deleted.
* **Abandoned carts and browse** — prints your Dotdigital Tag and feeds it what the Tag documentation asks for: who the visitor is (including a guest who types an e-mail at checkout), the cart on every page, the product being viewed and the completed purchase. Optional abandoned cart program ID and delay.
* **Timeline events** — "Order placed" and "Order refunded" on the contact timeline (Dotdigital CXDP package).
* **SMS about the order** — a text to the billing phone when the order is processing, completed, on hold, cancelled or refunded, through the Dotdigital Omnichannel API (SMS pay as you go).
* **Past orders and products** — sends the catalogue and the orders of the last 24 months in the background with Dotdigital bulk imports, five at most at a time, and reads back how many records were imported and rejected.
* **Journal** — every call with its result, and a "Send this order to Dotdigital now" button on the order screen.
* Updates from catcode.com.ua.

The licence runs for 1-5 years and includes updates and support for that term; a purchased licence keeps its Pro features after the term ends. One key covers two sites: the shop and its test copy.

Dotdigital is a trademark of its owner. This plugin is an independent integration made by CatCode; it is not an official plugin of Dotdigital and is not affiliated with or endorsed by it. You need your own Dotdigital account and an API user.

== External services ==

The plugin connects to the Dotdigital Marketing API ([dotdigital.com](https://dotdigital.com/), API documentation at [marketing.developer.dotdigital.com](https://marketing.developer.dotdigital.com/)) at `r1-api.dotdigital.com`, `r2-api.dotdigital.com` or `r3-api.dotdigital.com` — the region of your account — and only after you enter an API user and its password.

* When you press "Check connection": your API user and password, to read the summary of your account (name, region).
* When you press "Load lists from Dotdigital": the same credentials, to read the names of your lists.
* After a checkout where the buyer ticked the sign-up box: the buyer's e-mail address, first and last name, the chosen list and the consent record (checkbox text, time, checkout page address, IP address and browser user agent).
* Pro, after an order reaches a chosen status: the order (number, totals, currency, date, payment and delivery method, billing and delivery address, products) and, when switched on, customer totals and timeline events; for SMS the billing phone number and the text.
* Pro, when a product is saved or deleted: the product's name, prices, SKU, URL, image address, stock and categories.
* Pro, with the Dotdigital Tag switched on: the Tag code you paste is loaded by visitors' browsers from Dotdigital's servers, and receives the cart, the viewed product, the completed purchase and the visitor's e-mail address once it is known. The plugin keeps the id of the current cart in a first-party cookie, ccddg_cart (random, 30 days from the last cart change, removed after the purchase), so Dotdigital sees one cart from the first item to the order.

[Dotdigital privacy policy](https://dotdigital.com/terms/privacy-policy/) · [Dotdigital terms](https://dotdigital.com/terms/)

== Installation ==

1. Upload the plugin and activate it. WooCommerce must be active.
2. In Dotdigital go to Settings → Access → API users and add an API user for the shop.
3. WooCommerce → **Dotdigital**: enter the API user and its password and press "Check connection".
4. Press "Load lists from Dotdigital", choose a list, turn on the checkbox, check its text and save.
5. Place a test order with the box ticked: the order notes show that the buyer was added to the list.

== Frequently Asked Questions ==

= Do I need a Dotdigital account? =

Yes, with an API user. Creating an API user needs the account owner or a user with the "Can manage account" permission.

= Is anyone added without ticking the box? =

No. Only buyers who tick the box are sent to Dotdigital.

= A buyer was not added. Where do I see why? =

In the Dotdigital box and the notes of the order.

= "HTTP 403" when I check the connection =

Dotdigital answers 403 when the call goes to another region than the one of your account. "Check connection" picks the right region; save the settings after it.

== Changelog ==

= 1.0.1 =
* Maintenance release, no changes in the checkout sign-up.
* Pro, existing orders and products: the background send reads every finished state Dotdigital reports, so it goes on without long pauses and the journal shows the result of each import.
* Pro, Dotdigital Tag: a purchase paid on a payment page the buyer did not come back from is reported on the buyer's next visit, and the next cart gets its own id.
* Pro, Dotdigital Tag: the cart id is kept for as long as the cart is in use.

= 1.0.0 =
* First release.
