=== CoverMyOrder ===
Contributors: imrouf
Tags: woocommerce, shipping, shipping protection, claims, order protection
Requires at least: 6.3
Tested up to: 7.0
Requires PHP: 7.4
WC requires at least: 8.0
WC tested up to: 9.4
Stable tag: 1.8.2
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Self-hosted shipping protection for WooCommerce. Collect an opt-in fee, let customers file claims, resolve via refund, and keep 100% of premiums.

== Description ==

**CoverMyOrder** is a customer-facing shipping protection platform built directly into WooCommerce. Customers opt in to a small protection fee at checkout — when a delivery goes wrong (lost, damaged, or stolen) they file a claim through a self-serve portal. Operators review claims, approve or deny, and issue WooCommerce refunds.

Unlike SaaS alternatives, you keep the full protection fee in your own account. A built-in reserve ledger tracks every dollar collected and paid out so you always know your loss ratio at a glance.

= Free Features =

**Checkout**

* Customer opt-in protection widget — WooCommerce Cart/Checkout Block and classic shortcode fallback
* Single flat-fee protection plan
* Branded opt-in badge with 2 color theme presets
* Post-purchase confirmation card and customer order notification email

**Claims Portal**

* Self-serve customer claim portal — WooCommerce My Account integration, Gutenberg block, and shortcode
* Evidence upload — photos, videos, PDFs (up to 10 files at 10 MB each by default; filterable)
* Manual carrier tracking entry
* AfterShip inbound webhook for automatic tracking event ingestion (AfterShip account required)

**Operator Dashboard**

* Dashboard with KPIs: fees collected, active claims, reserve balance, and loss ratio; sparkline charts; traffic-light health indicator
* WordPress dashboard widget ("CoverMyOrder — At a Glance") on the wp-admin home page
* Claims queue with status chips, search, overdue badge, and one-click approve & issue WooCommerce refund
* Customer risk profile sidebar on each claim
* Reserve ledger with full running balance
* HTML email templates for every claim status: submitted, approved, denied, and resolved

**Branding**

* 2 colour theme presets
* Hardcoded badge title and description (matches plugin name)
* Cart badge always enabled

**Setup & Compatibility**

* First-run setup wizard — pick a plan, enable the badge, configure tracking
* HPOS (High-Performance Order Storage) compatible
* WooCommerce Cart and Checkout Blocks compatible
* REST API (read endpoints)
* Multilingual ready — Text Domain: covermyorder

**Why CoverMyOrder?**

*Self-hosted
*Keep 100% of protection fees
*WooCommerce native
*HPOS Ready
*Blocks compatible
*No monthly platform fees

= Premium Add-On =

Optional [CoverMyOrder Premium](https://covermyorder.com/pricing) adds advanced features that are NOT part of the free WordPress.org plugin:

* Multiple protection plans — unlimited active tiers (e.g. Basic / Standard / Premium) instead of the free plugin's single plan
* Percentage-of-cart pricing and multiplier/cart-total coverage caps, in addition to flat fee + fixed cap
* Per-category price overrides (e.g. charge more for electronics or fragile items)
* Full badge customization — toggle it off, custom title/description/logo, 5 additional color presets plus a custom hex picker, and per-surface placement
* Rule-based fraud risk scoring on every claim
* Auto-claim from AfterShip carrier webhooks (no operator action needed)
* Carrier recovery tracking (auto-opens a FedEx / UPS / USPS recovery record to file when a claim is approved)
* SMS notifications via Twilio
* Carrier-level analytics and reporting
* White-label for agencies
* Multi-store management
* Priority email support

The Premium add-on is a separate plugin distributed through Freemius. It is not included in this free plugin and is not required for the free plugin to work.

== Installation ==

**Via WordPress admin (recommended)**

1. Go to **Plugins → Add New** and search for "CoverMyOrder".
2. Click **Install Now**, then **Activate**.
3. The first-run setup wizard opens automatically — follow the three steps to choose a plan, preview the badge, and configure the tracking webhook secret.

**Manual installation**

1. Upload the `covermyorder` folder to `/wp-content/plugins/covermyorder/`.
2. Activate the plugin from the **Plugins** screen.
3. The setup wizard launches on your first admin page load.

== Frequently Asked Questions ==

= Is WooCommerce required? =

Yes. WooCommerce 8.0 or higher must be installed and active. The plugin will display an admin notice and will not load if WooCommerce is absent.

= Is this regulated insurance? =

No. CoverMyOrder is a merchant-funded reserve product — you collect a small fee from opted-in customers and pay claims out of that reserve. It is not a regulated insurance product. Consult legal counsel if you are unsure about compliance requirements in your jurisdiction.

= Is there any feature in the code that does not work for free users? =

No. Every feature included in the free plugin is fully functional for everyone. The optional Premium add-on is a separate plugin (not included here) that adds completely new features such as fraud risk scoring, SMS notifications, and carrier recovery tracking.

= Is the plugin compatible with HPOS? =

Yes. CoverMyOrder declares full HPOS (High-Performance Order Storage) and Cart/Checkout Block compatibility before WooCommerce initialises.

= Where is my data stored? =

All data — plans, protections, claims, and reserve ledger entries — is stored in your own WordPress database. No claim, order, or customer data is ever sent to a third party.

= Does this plugin use Freemius? =

No. This free plugin does not bundle Freemius, or any other licensing or analytics SDK, and makes no connection to Freemius at all. The separate Premium add-on (not included in this download, and not distributed through WordPress.org) is sold through Freemius and discloses its own data practices independently.

= Can I use CoverMyOrder on a WordPress Multisite network? =

Yes. The plugin has no single-site assumptions and is compatible with multisite. Network-wide activation is supported.

= How do I customise the badge appearance? =

Go to **CoverMyOrder → Branding** to choose between the 2 color theme presets. Badge title and description text are hardcoded in the free plugin. Developers can override any front-end template by copying it to `themes/{your-theme}/covermyorder/` inside your active theme.

= Do customers need an account to file a claim? =

Yes. The claim portal integrates with WooCommerce My Account. Customers must be logged in to view their protected orders and submit a claim.

= Where can I get support? =

Use the [support forum](https://wordpress.org/support/plugin/covermyorder/) on WordPress.org for community support. Premium licence holders get priority support via [covermyorder.com/support](https://covermyorder.com/support).

== Third-Party Services ==

This plugin connects to the following external services. Please review their policies before using the plugin in a production environment.

= AfterShip (optional) =

If you enable the AfterShip integration under **CoverMyOrder → Settings → Tracking**, AfterShip will deliver tracking event payloads to your site via an inbound webhook. Your site acts as a receiver only — no data is sent *from* your site to AfterShip by this plugin. An AfterShip account and a separately configured webhook are required.

* [AfterShip Privacy Policy](https://www.aftership.com/legal/privacy) · [Terms of Service](https://www.aftership.com/legal/terms-of-service)

= CoverMyOrder Hub (optional, off by default) =

CoverMyOrder can poll **covermyorder.com** for important security alerts, end-of-life notices, and product announcements, then surface them as wp-admin notices. This feature is **OFF by default** and is only activated when you explicitly tick **Receive important CoverMyOrder updates** under **CoverMyOrder → Settings → Data & privacy**. No outbound network calls happen until you opt in.

**When a connection is made (only after opt-in):**

* Once per day — your site fetches the latest message list (read-only HTTP GET).
* Once per week — your site sends a small "heartbeat" so we know it is still alive.
* On notice dismiss / CTA click — your site sends a single non-blocking ping with the message ID.

**Endpoint:** `https://covermyorder.com/wp-json/sg-hub/v1/`

**What data is sent:** plugin version, WordPress version, PHP version, WooCommerce version, locale, best-effort country code, and your site URL. Note that the hub stores a SHA-256 hash of the site URL for analytics in addition to the raw URL for operator-facing diagnostics.

**What is never sent:** customer records, order details, claim data, evidence files, email addresses, IP addresses, or anything related to your store's protected orders.

**How to revoke consent:** untick the same checkbox. The plugin clears its WP-Cron schedule the moment the option is turned off, and the in-admin notices stop appearing on the next page load.

* CoverMyOrder [Privacy Policy](https://covermyorder.com/privacy)

== Screenshots ==

1. **Dashboard** — KPIs (fees collected, active claims, reserve balance, loss ratio), sparkline charts, and traffic-light health indicator.
2. **Claims queue** — status chips, search, overdue badge, and one-click approve & refund.
3. **Claim detail** — evidence gallery, customer risk profile sidebar, carrier tracking timeline, and resolution panel.
4. **Checkout widget** — customer opt-in toggle with plan name, fee, and coverage description.
5. **Setup wizard** — three-step onboarding: plan picker, badge preview, webhook configuration.
6. **Branding settings** — live badge preview with theme picker and text overrides.
7. **Reserve ledger** — running balance with collection and payout line items.

== Changelog ==

= 1.8.2 =
* Added an affiliate-program link to the "Why upgrade" screen — the free plugin never loads Freemius, so this points out to the hosted application on covermyorder.com instead of an in-admin form.

= 1.8.1 =
* Security: portal sign-in (order number + email) now throttles repeated failed attempts per IP — previously unlimited, making the order-id/email pair guessable against a known customer.
* Security: "Shipping protection" in My Account now cross-checks the underlying WooCommerce order's customer id instead of trusting the account's (self-editable, unverified) email alone.
* Security: an approved claim can no longer be set above the amount originally requested; a refund can no longer be issued above a claim's approved amount.
* Fix: the reserve-ledger debit for a refund now runs before the WooCommerce refund call, not after, so a transient failure rolls back cleanly instead of risking a duplicate refund on retry.
* Fix: approve/deny/close decisions on a claim are now applied against a freshly locked read, closing a race where two concurrent decisions (e.g. a double-clicked Approve button) could both apply and fire conflicting notifications.
* Fix: per-category pricing discount rules (percentage or flat) can now actually apply — a comparison bug meant only surcharges ever took effect.
* Security: REST API idempotency keys are now scoped per caller, preventing one caller's cached response from ever being replayed to a different caller reusing the same key.
* Security: anonymous REST API callers no longer share a single site-wide rate-limit bucket per route — each client is now limited independently.

= 1.8.0 =
* Version alignment with the Premium add-on's 1.8.0 release (a redesign of its Plans admin screen — see the Premium add-on's own changelog for details). No functional changes in the free plugin this release.

= 1.7.0 =
* New: protection plans replace the old single opt-in-fee flag internally. Free still ships and enforces exactly one editable plan (name, flat fee, fixed coverage cap) at CoverMyOrder → Plans — multiple tiers, percentage pricing, and coverage multipliers require the Premium add-on.
* New: CoverMyOrder → Branding screen — choose a color preset and edit the cart-toggle title, description, opt-in/opt-out labels, and thank-you copy. The trust badge itself is unchanged (still mandatory-on with a hardcoded title/description); full badge customization requires Premium.
* New: category price-override pricing engine ships in free/core, but there is no free admin screen to configure it — Premium supplies the settings UI that turns it on.
* New: `GET /covermyorder/v1/plans` and `POST /covermyorder/v1/plans/quote` public REST endpoints for headless integrations and the Cart/Checkout Block.
* Changed: checkout now persists a `plan_id` instead of a boolean opt-in flag; existing orders and integrations that read the legacy flag continue to work.

= 1.1.0.2 =
Major release prepared for WordPress.org Plugin Directory submission. Recommended for all users.
