=== Preflight - store readiness audit for WooCommerce ===
Contributors: lightningbyrd
Tags: woocommerce, shipping zones, checkout, diagnostics, audit
Requires at least: 6.0
Tested up to: 6.7
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Checks whether your WooCommerce store can actually take an order, before a customer finds out it cannot. Read only, offline, no account.

== Description ==

WooCommerce tells you about your server. WordPress tells you about your site. Nothing tells you about your shop.

There is a whole class of WooCommerce misconfiguration that produces no error, no log line and no support ticket. It just quietly stops money arriving. A shipping zone that exists but has no method. A gateway switched off by a plugin update. A variable product whose variations lost their prices, which WooCommerce then shows to customers as "out of stock and unavailable". A checkout page rebuilt in a page builder that no longer contains a checkout. A coupon whose rules can never fire.

Preflight looks for all of it, grades every finding by how much it hurts, and tells you in plain English what a customer sees.

= The Sell Test =

The headline feature, and the reason this plugin exists. Preflight builds a real cart in memory with a representative product and walks the four steps a customer walks: cart, shipping resolution, payment gateway availability, tax calculation. It does this once per country you sell to, and reports where the path breaks.

"Germany: no shipping method matches. Canada: fine. Australia: shipping fine, no gateway available."

It never creates an order. It never charges anything. It never sends mail. While it runs, a guard blocks outbound mail, replaces the WooCommerce mailer with a no-op, refuses outbound HTTP, and aborts the whole run if anything tries to insert an order. The cart is emptied and your session restored afterwards, including when the run fails.

= Everything else in the free plugin =

* **Shipping coverage map.** Every country you sell to, matched against your zones the way WooCommerce matches them. Flags countries with no matching zone, zones with no enabled methods, zones with no regions, postcode-only zones that can never match, blank flat rate costs, and zone shadowing where a broader zone earlier in the list masks a narrower one.
* **Checkout gate audit.** Guest checkout off with no way to register. A terms tickbox enforced against an unpublished page. No enabled gateway at all. A gateway left in test or sandbox mode. An incomplete store address. A decimal separator identical to the thousand separator. A cart, checkout or my-account page that is unassigned, trashed, or no longer contains the block or shortcode it is supposed to.
* **Unpurchasable products report.** Published products a customer can never buy, with the reason and a direct edit link: no price, variable with no priced variation, out of stock with backorders off, managed stock at zero, downloadable with no file, variations missing attribute values, hidden from the catalog while something links to it.
* **Coupon collision check.** Expired coupons still in circulation, exhausted usage limits, a minimum spend above the maximum spend so the coupon can never fire, percentages over 100, coupons restricted to products that no longer exist, allow lists cancelled out by exclusion lists, free shipping coupons with no free shipping method anywhere to unlock, and clashes between individual-use coupons.
* **Severity triage and WP-CLI.** Every finding is Critical, Warning or Notice, with a "what a customer sees" line and a direct link to the setting. `wp lb-preflight run` exits non-zero on Critical so it can gate a deploy.

Forty-seven individual assertions across five checks, in the free plugin, in full. Nothing here is a teaser.

= The safety posture, stated plainly =

Preflight is **read only**. It writes exactly two options of its own, its settings and its last report, and nothing else. There is no code path in this plugin that writes a WooCommerce setting, a product, a coupon or an order.

It also never phones home. No external services, no API keys, no telemetry, no licence check, no update ping. Everything runs against your own database, offline, and the plugin is useful on a store with no internet-facing traffic at all.

Nothing runs on the visitor path. An audit happens when an administrator clicks Run, or when WP-CLI asks for one.

= Honest limits =

* The Sell Test rehearses one representative product. A catalog that mixes shippable, virtual and downloadable goods should be rehearsed more than once.
* The rehearsal walks WooCommerce, not your theme. It cannot see a checkout form that a page builder failed to render, and it cannot see a JavaScript error on the checkout page.
* A gateway that decides at payment time whether to accept a card cannot be tested without a card. Preflight reports availability, which is the part that breaks silently.
* The gateway test-mode check reads the common settings field names. A gateway that stores its sandbox flag somewhere unusual will not be flagged.
* The catalog check has a configurable row cap and a 15 second budget so it cannot time out a large store.
* WooCommerce 11.1.0 added its own inline shadowing warning to the Shipping zones screen. On that version and later Preflight's shadowing check is a second opinion. On older versions it is the only warning you get.
* On multisite, Preflight audits the current site only.

= Pro =

Everything described above is free, forever. A separate paid add-on, Preflight Pro, adds scheduled re-audits with drift alerts on state changes only, a WooCommerce settings change log with a diff and a one-click revert, custom rules, a branded printable client report, a multi-store dashboard across sites you own, and a batched catalog hygiene sweep. Pro is continuity, history, scope and workflow. It unlocks no check that the free plugin pretends to have.

There is exactly one mention of Pro inside this plugin: a single row at the bottom of its own Help tab. No admin notices, no dashboard banners, no nags.

== Installation ==

1. Plugins, Add New Plugin, Upload Plugin, choose the zip, Install Now, Activate.
2. Go to WooCommerce, Preflight.
3. Click "Run the audit now". Nothing is changed, so there is no reason to wait for a maintenance window.
4. Fix the criticals first. Each one means a real customer, somewhere, cannot complete a purchase today.

Requires WooCommerce. Requires PHP 7.4 or newer and WordPress 6.0 or newer.

== Frequently Asked Questions ==

= Does the Sell Test create real orders? =

No. It never has and it never will. There is no call to any order-creating API anywhere in the plugin. On top of that the rehearsal arms a guard that blocks mail, blocks outbound HTTP, and aborts the entire run with a logged error if anything tries to insert an order post or fire an order creation hook. If you ever see a Preflight rehearsal produce an order, that is a bug of the most serious kind and we want to hear about it.

= Will it change my settings to fix things? =

No. The free plugin is read only, deliberately. It shows you what is wrong, tells you what a customer sees, and links you straight to the setting. You make the change.

= Does it send email? =

The free plugin has no email feature at all. Not on activation, not after an audit, not ever.

= Does it need an account, an API key or an internet connection? =

None of the three. Preflight makes no outbound request of any kind.

= Is this the same as the WooCommerce System Status Report? =

No. The System Status Report is a technical environment dump: PHP version, memory limit, template overrides, database tables. It does not assert anything about whether the store can take an order, and it applies no severity to what it lists. WooCommerce's own issue asking for that triage has been open in the core repository since 2020. Preflight is about commerce configuration, not about the server.

= Is this the same as WordPress Site Health? =

No. Site Health is WordPress-level: PHP, updates, HTTPS, loopbacks. It has no commerce awareness at all.

= How is it different from an activity log plugin? =

An activity log records that an option changed. Preflight tells you whether the current configuration lets a customer buy something. They answer different questions and work well together.

= Will it slow my store down? =

No. Nothing runs on the visitor path. An audit runs only when you click Run or when WP-CLI asks. The catalog pass has a row cap and a wall-clock budget.

= Does it work on large catalogs? =

Yes, within a documented cap. The catalog check reads at most the configured number of published products per run, newest first, and stops at a 15 second budget rather than timing out.

= Does it support the block checkout as well as the classic shortcode checkout? =

Yes. Preflight detects which one the assigned checkout page actually renders and reports it, and it flags a page that contains neither.

= Is it compatible with High Performance Order Storage? =

Yes, and it declares compatibility. Preflight does not read orders at all in this version, and everything it does read goes through WooCommerce's own APIs rather than raw postmeta.

= What happens when I delete the plugin? =

Settings and the last report are removed. The run history is deliberately kept, because it is the only record of when a store's readiness changed. Define `LB_PREFLIGHT_REMOVE_ALL_DATA` as true in wp-config.php to remove that too.

== Screenshots ==

1. The Report tab: every finding triaged Critical, Warning or Notice, each with a plain-English "what a customer sees" line and a direct link to the setting.
2. The Sell Test: a per-country matrix of cart, shipping, payment and tax, with the step that blocked each country named.
3. The shipping coverage map: every country you sell to matched against the zone WooCommerce would actually use.
4. The unpurchasable products report, with the reason per product and a direct edit link.
5. Settings: which checks to run, which countries to rehearse, and the documented scan caps.
6. Help: what Preflight does, what it never does, and the honest limits.

== Changelog ==

= 1.0.0 =
* Initial release.
* The Sell Test: an in-process purchase rehearsal per country, with a guard that blocks mail, blocks outbound HTTP and aborts on any attempt to create an order, plus guaranteed cart teardown and session restore.
* Shipping coverage map with zone matching, catch-all detection and shadowing detection.
* Checkout gate audit covering payment, accounts, terms, pages, store address and currency formatting, for both block and classic checkout.
* Unpurchasable products report with nine reason codes and per-product edit links.
* Coupon collision check with eleven reason codes.
* Severity triage across all findings, with a "what a customer sees" line on every one.
* WP-CLI: `wp lb-preflight run` and `wp lb-preflight last`, table or JSON, with a configurable failure floor and a non-zero exit code for CI.
* Documented extension hooks for add-ons: `lb_preflight_register_checks`, `lb_preflight_collect_state`, `lb_preflight_findings`, `lb_preflight_admin_tabs`, `lb_preflight_render_tab`, `lb_preflight_report_generated`.
* No custom tables. Settings, the last report and a capped 30-entry history live in options that are not autoloaded.
