=== Reloadify for WooCommerce ===
Contributors: reloadify
Tags: reloadify, woocommerce, marketing automation, email, abandoned cart
Requires at least: 6.4
Tested up to: 7.0
Requires PHP: 7.4
WC requires at least: 8.2
WC tested up to: 10.8
Stable tag: 2.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Connects your WooCommerce store with the Reloadify marketing automation platform.

== Description ==

Reloadify for WooCommerce exposes your store data to the Reloadify marketing
automation platform through a secured REST API, and adds an abandoned-cart
recovery flow. It is the WooCommerce counterpart of the Reloadify extension for
Magento 2 and provides the same feeds and functionality.

= Feeds (REST API) =

All feeds live under the `reloadify/v1` REST namespace and require a Bearer
access token, except the public cart restore endpoint.

* Settings — extension status and environment versions.
* Languages — the store (WooCommerce is single-store).
* Profiles — registered customers.
* Subscribers — newsletter opt-ins.
* Products — catalog products, plus a `products-delta` incremental feed.
* Variants — product variations.
* Categories — product categories.
* Orders — orders with line items and addresses.
* Carts — tracked (abandoned) shopping carts with a recovery URL.
* Reviews — product reviews.

= Shopping carts in the WooCommerce REST API =

Abandoned carts are additionally exposed inside the WooCommerce v3 REST API at
`/wp-json/wc/v3/reloadify/shopping_carts`, returning the carts of every
language. That endpoint authenticates with WooCommerce API keys (consumer key
and secret), so a sync that already uses the WooCommerce v3 API needs no
changes. It accepts `page`, `per_page` and `status` (`active`, `recovered` or
`all`) and returns the `X-WP-Total` and `X-WP-TotalPages` headers.

This endpoint keeps the long-standing Reloadify response format: a `meta` array
with the `email`, `first_name`, `last_name`, `language` and `billing_country`
keys, `product_ids` as a list of plain product ids, and ISO 8601 timestamps.
The `reloadify/v1` endpoints use the newer nested format instead.

= Abandoned cart recovery =

The plugin tracks shopping carts in a dedicated table, including the name and
email address as soon as a visitor enters them at checkout. Each cart gets a
unique recovery URL that restores the cart and sends the customer to the cart
page.

= Authentication =

On activation an access token is generated. Provide the REST API base URL and
the token (shown on the settings page) to Reloadify. Requests authenticate with
`Authorization: Bearer <token>`. The WooCommerce API cart endpoint accepts
either WooCommerce API keys or this token.

== Installation ==

1. Upload the `reloadify-for-woocommerce` folder to `/wp-content/plugins/`.
2. Activate the plugin through the *Plugins* menu in WordPress.
3. Go to *WooCommerce > Reloadify*, enable the connection and copy the
   REST API base URL and access token into your Reloadify account.

== Frequently Asked Questions ==

= How do I test a feed? =

Call a feed with the access token, for example:

`curl -H "Authorization: Bearer <token>" \`
`  https://your-store.test/wp-json/reloadify/v1/language/1/products`

= The cart recovery link does not open the cart, why? =

Check *WooCommerce > Settings > Site visibility*. While a store is set to
"Coming soon", visitors who are not logged in are redirected away from the
storefront, including the cart page. Set the site to "Live" (or limit coming
soon mode to store pages only) to test recovery links as a real customer would.

= How does the newsletter opt-in work? =

Enable the checkbox under *WooCommerce > Reloadify > Newsletter*. Customers
with an account get the opt-in stored in their user meta (default
`reloadify_newsletter_opt_in`), guests get it stored on their order. Both end
up in the subscribers feed, deduplicated by email address. An existing opt-in
is never removed by a later order in which the box is left unchecked.

If you already populate the opt-in meta key from another newsletter plugin,
those customers keep appearing in the feed as before.

The feed reads at most 5000 accounts and 5000 guest orders per request; raise
this with the `reloadify_subscriber_query_limit` filter on very large stores.

= Are guest customers included in the profiles feed? =

No. The profiles feed lists accounts only. Guest details are available inside
the orders and carts feeds, and guests who opt in to the newsletter appear in
the subscribers feed. Every account is listed regardless of its role, so an
order can never reference a profile that is missing from the feed; narrow this
with the `reloadify_profile_roles` filter.

= Which fields require a recent WooCommerce version? =

The native GTIN field (WooCommerce 9.2+), product brands taxonomy
(WooCommerce 9.6+) and Cost of Goods (WooCommerce 9.5+) are used when
available. On older versions, map these to a custom meta key or attribute on
the settings page.

== Changelog ==

= 2.0.0 =
* First public release. Brings together the REST feeds, the abandoned cart
  tracking and recovery flow, the newsletter opt-in and the WooCommerce API
  compatibility endpoint.
* Translations are now served by WordPress.org, so no language files are
  bundled.
* Declares WooCommerce as a required plugin, so WordPress warns before the
  plugin is activated without it.

= 1.3.1 =
* Every completed order now also stores the `wc_reloadify_subscriptions_consent`
  order meta key (`yes`/`no`) used by earlier plugin versions, so an existing
  Reloadify import picks the opt-in up without changes. The newer keys remain.
* The subscribers feed and the orders feed recognise the older key as well, so
  opt-ins collected before an upgrade are not lost.

= 1.3.0 =
* The WooCommerce API cart endpoint returns the original Reloadify format
  again: a `meta` array with `email`, `first_name`, `last_name`, `language` and
  `billing_country`, `product_ids` as plain ids, a string `id` and ISO 8601
  timestamps. Existing syncs need no change.
* The language of a cart is now stored per cart, resolved through WPML or
  Polylang where available, so multilingual stores no longer report a single
  language for every cart. The billing country is stored alongside it.

= 1.2.1 =
* Added the newsletter opt-in checkbox back. It is registered on the block
  checkout through the Additional Checkout Fields API and on the classic
  checkout through the traditional hooks, with a configurable label and
  default state.
* Optionally shows the checkbox on the cart page as well. The option is hidden
  when the cart page uses the Cart block, which does not support custom fields.
* Customers with an account get the choice written to their profile, so they
  appear in the subscribers feed immediately.
* Guests who opt in at checkout are stored on their order and are now included
  in the subscribers feed, deduplicated by email address.
* The orders feed exposes the newsletter choice as `subscribed_to_newsletter`.

= 1.1.0 =
* Added the shopping cart feed to the WooCommerce v3 REST API at
  `wc/v3/reloadify/shopping_carts`, authenticated with WooCommerce API keys.
* Carts are now updated when a visitor enters or changes their name or email
  address at checkout, on both the classic and the block checkout.
* Cart recovery links are handled before other redirects, so they also work
  while the site is in coming soon mode.
* The database schema and settings are now also created after an in-place
  plugin update, not only on activation.
* The profiles feed no longer skips customers whose account has another role,
  so orders can no longer reference a profile that is missing from the feed.
  Use the `reloadify_profile_roles` filter to limit it to specific roles.
* Following a recovery link now moves the tracked cart to the returning
  visitor's session instead of leaving a duplicate cart behind.
* A recovery link for a cart that was already ordered now shows a notice
  instead of refilling the cart.

= 1.0.0 =
* Initial release — REST feeds, abandoned cart tracking and recovery, admin
  settings and self-test.
