=== OrderCtrl Bridge ===
Contributors: orderctrl
Tags: woocommerce, customer portal, single sign-on, order tracking, returns
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 8.1
Requires Plugins: woocommerce
Stable tag: 2.2.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Connects WooCommerce to your OrderCtrl account: one customer sign-in for your store and portal, plus optional package protection at checkout.

== Description ==

OrderCtrl Bridge connects your WooCommerce store to [OrderCtrl](https://orderctrl.io/). It adds the parts that have to run inside your store.

**An OrderCtrl account is required.** The plugin does nothing until you connect your store to it. There's a free plan.

= What this plugin does =

**One customer sign-in**

* **Portal to store:** a customer who signs in to your OrderCtrl portal with an email code is signed in to My Account too. If they don't have a store account yet, the plugin creates a WooCommerce customer account with that email address.
* **Store to portal:** a customer who signs in on My Account is signed in to the portal, then brought back.
* **Customers only.** Administrators, shop managers and anyone who can edit content are never signed in or redirected this way.
* **Your choice.** Turn it on or off in your OrderCtrl settings.

**Package protection at checkout (optional, off until you turn it on)**

* Offered in the Checkout block and Cart block, or in the classic checkout and cart (CheckoutWC positions included).
* A flat fee, a percentage, a percentage with a minimum, or tiers by cart value, with your own name, wording and colors.
* The fee is paid to your store. OrderCtrl takes no share. You decide what protection covers.
* The price shown is the price charged, and each protected order is flagged in WooCommerce with a "Protected" column on the orders list.

**In wp-admin**

* An **OrderCtrl** menu with the connection status, the settings OrderCtrl sends (read-only; you edit them in OrderCtrl) and your protected-order totals.
* Compatible with HPOS (High-Performance Order Storage) and the Cart and Checkout blocks. Translation-ready.
* Deleting the plugin removes every setting it stored.

= The OrderCtrl service =

**One store. One experience.** OrderCtrl is the unified platform for WooCommerce: orders, tracking, returns, subscriptions and support in one place, for you and for your customers.

The features below run in your OrderCtrl account, which connects to your store through the WooCommerce REST API. They aren't part of this plugin and don't need it.

* **Customer portal:** one passwordless place on your own domain for orders, tracking, issues and subscriptions.
* **Shipment tracking:** every box across 50+ carriers, with tracking numbers saved to WooCommerce.
* **Returns, exchanges and claims:** customers pick a fix in a few taps, and your rules decide what to offer.
* **Order editing:** customers fix the shipping address or cancel before the order ships.
* **Subscription self-service:** skip, pause, swap products or change frequency, on WooCommerce Subscriptions.
* **Proactive emails:** stalled and late shipments are spotted and customers hear from you first.
* **Helpdesk context and analytics:** order history inside your helpdesk, and claim and delivery numbers on one screen.

== Installation ==

1. Install and activate WooCommerce.
2. In WordPress, go to **Plugins → Add New**, search for "OrderCtrl", then install and activate **OrderCtrl Bridge**.
3. [Create an OrderCtrl account](https://orderctrl.io/app/register) (free for up to 100 orders a month), or [sign in](https://orderctrl.io/app/login).
4. In OrderCtrl's setup wizard, connect your WooCommerce store and approve the WooCommerce access screen. OrderCtrl finds the plugin and configures it.
5. Turn on customer sign-in, and package protection if you want it, in OrderCtrl. Check the status any time under **OrderCtrl** in your WordPress admin menu.

== External services ==

This plugin connects your store to OrderCtrl, a service provided by OrderCtrl (https://orderctrl.io/). It doesn't contact OrderCtrl until you connect your store from your OrderCtrl account, and then only for the features you turn on there.

What is sent, and when:

* **When a customer signs in on your store's My Account page** (customer sign-in on): the customer's email address and WordPress user ID, so OrderCtrl can create a one-time sign-in link for your portal.
* **When a customer arrives from your OrderCtrl portal** (customer sign-in on): the one-time token in the link, so OrderCtrl can confirm it and return the customer's email address. If no store account has that address, the plugin creates a customer account.
* **When a customer signs out of your store** (customer sign-in on): the customer's email address, so their portal session ends too.

These requests go to your OrderCtrl app address (https://orderctrl.io by default) over HTTPS and carry your store's OrderCtrl API key.

OrderCtrl also calls this plugin's REST endpoints (`/wp-json/orderctrl/v1/...`) to save the connection and the package protection settings, authenticated with the WooCommerce REST API keys you approved when connecting. A public status endpoint returns only the plugin version and whether the plugin is configured.

Package protection fees are calculated in your store; this plugin sends no checkout or payment data. Order data reaches OrderCtrl through the WooCommerce REST API connection you approved.

* Terms of service: https://orderctrl.io/terms.html
* Privacy policy: https://orderctrl.io/privacy.html
* Data processing agreement: https://orderctrl.io/dpa.html
* Security: https://orderctrl.io/security.html

== Frequently Asked Questions ==

= Do I need an OrderCtrl account? =

Yes. The plugin connects your store to OrderCtrl and does nothing until it's connected. OrderCtrl is free for up to 100 orders a month, with 150 tracked shipments included; see [pricing](https://orderctrl.io/pricing.html).

= Do I need the plugin for order tracking, returns or subscriptions? =

No. OrderCtrl runs those through the WooCommerce REST API. The plugin adds customer sign-in and package protection at checkout.

= Does customer sign-in create accounts? =

Yes, when a customer signs in to your portal and no store account has their email address, the plugin creates a WooCommerce customer account for it. Developers can turn this off with the `orderctrl_bridge_sso_create_customers` filter.

= Do I have to offer package protection? =

No. It's off until you turn it on in OrderCtrl. When it's on, the fee is added to the order and paid to your store; OrderCtrl takes no share.

= Does it work with the Checkout block? =

Yes. Package protection appears in the order summary of the Checkout block (and the Cart block, if you turn that on), and in the classic shortcode checkout.

= Can I change the price or the wording? =

Yes, in OrderCtrl under Package protection: four ways to price it, your own name, title, description, tooltip, colors, and opted in by default or not. The changes reach your checkout automatically, and the plugin's admin page shows the current settings with a preview.

= Can staff or administrators be signed in through the portal? =

No. Customer sign-in only works for customer accounts. Accounts that can manage the store or edit content are never signed in or redirected by it.

= Is it compatible with HPOS? =

Yes, with High-Performance Order Storage and with the legacy order storage.

= What happens when I uninstall the plugin? =

Deleting the plugin removes its settings, including the connection and API key. Orders keep their package protection record.

= Where do I get help? =

Read the [OrderCtrl docs](https://orderctrl.io/docs.html), email support@orderctrl.io, or post in this plugin's support forum.

== Screenshots ==

1. One sign-in: customers who sign in to your portal with an email code are signed in to your store too.
2. Optional package protection in the WooCommerce Checkout block, paid to your store.
3. The OrderCtrl menu in wp-admin shows every setting OrderCtrl sends.
4. The OrderCtrl service: one login and one order record for your team and your customers.
5. The OrderCtrl service: a branded tracking page with every box in a split shipment.
6. The OrderCtrl service: returns, exchanges and claims in a few taps.
7. The OrderCtrl service: stalled shipments spotted, and customers emailed their options.

== Changelog ==

= 2.2.2 =
* Security: WooCommerce API keys are held to their scope on the plugin's REST routes. Reading settings needs read access, changing them needs write access.
* Changed: the "Connect your store" notice stays hidden once dismissed.

= 2.2.1 =
* Changed: the plugin's web page is https://orderctrl.io/woocommerce.html (Plugin URI). The Author URI header is removed.

= 2.2.0 =
* Changed: settings are stored under `orderctrl_` option names. Existing settings move over automatically.
* Changed: the Package Protection admin page address is now `admin.php?page=orderctrl-protection`.
* Security: stricter sanitizing of request values and escaping of the checkout tooltip.
* Changed: new wording on the plugin screens and listing.

= 2.1.0 =
* Security: the public status endpoint no longer returns the connection details or the API key.
* Security: removed the `/sso-initiate` and `/sso-login` routes and the `/login` REST route.
* Security: requests no longer turn off TLS certificate checks or allow internal hosts for the whole site.
* Security: customer sign-in refuses staff accounts, runs only when turned on in OrderCtrl, and only redirects to your store, OrderCtrl and your portal.
* Fix: package protection charged $0 for the "percentage with minimum" and "tiered" prices. The fee shown, the fee charged and the amount saved on the order now always match.
* New: package protection in the Cart and Checkout blocks.
* New: the widget title, description and "ticked by default" settings from OrderCtrl are used.
* New: the OrderCtrl dashboard in wp-admin shows real protected-order counts and fees.
* Changed: package protection is off until you turn it on in OrderCtrl.
* Changed: the OrderCtrl admin pages (Dashboard, Package Protection, SSO Settings) show the settings OrderCtrl sends, read-only; they are edited in OrderCtrl. The API key is never displayed.
* Changed: the orders list "Protection" column reads the order's protection record instead of the fee name.
* Changed: uninstalling removes every setting, including the API key.
* Requires WordPress 6.5, PHP 8.1 and WooCommerce 8.0 or later.

= 2.0.0 =
* Combined OrderCtrl SSO Bridge and Package Protection for WooCommerce into one plugin.

== Upgrade Notice ==

= 2.2.2 =
Tightens REST API key checks. Update when convenient.

= 2.2.1 =
No code changes from 2.2.0. Update when convenient.

= 2.2.0 =
Settings move to new option names automatically. Includes the 2.1 security fixes; update right away if you're on an older version.
