=== Tadrik Safe Updates – Roll Back Updates That Break Checkout for WooCommerce ===
Contributors: tadrik
Tags: rollback, updates, checkout, auto updates, woocommerce
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 0.1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Places a test order after every plugin and theme update. If checkout broke, the previous version is put back within seconds and you get an email.

== Description ==

A plugin update that breaks checkout usually goes unnoticed until a customer complains, hours or days later. The rest of the store looks fine, so uptime monitors stay green while every order fails.

Tadrik Safe Updates tests your checkout right after each update. Before the update it saves a copy of the current version. After the update it places a test order through your checkout. If something that worked before the update stops working, it puts the previous version back, tests again, and emails you what broke. Automatic updates then skip that broken version, and the Plugins screen warns before you install it by hand; a newer version is updated and tested the same way.

It covers updates from the Plugins and Updates screens (one or many at once), WordPress's automatic background updates, and WP-CLI.

**What the test does**

* Loads the home page.
* Adds a hidden test item to a cart.
* Opens the checkout page and checks the checkout form is there (block checkout or classic).
* Reads the cart the way the checkout block does, and notes which payment methods are offered.
* Places a test order through the Store API, the same way the checkout block does, paid with a test payment method that only exists inside the test.

The test order takes no money, sends no email and no webhook, and is deleted seconds later. Shoppers can never see or buy the test item, and they never see the test payment method.

**Compared with before, not with perfect**

A check only counts when it passed before the update. A store without guest checkout or with a required custom field won't get false rollbacks: the test notices what an update changed, not what was already different.

If an update makes a payment method disappear from checkout (say bank transfer or PayPal), that counts as broken too.

**Also included**

* A daily checkout test that emails you when something stopped working (on by default; can be turned off).
* "Run a test now" and an update log under WooCommerce > Safe Updates.
* Alerts to any email addresses you choose, so the developer who looks after the store hears about it first.

**What it does not do**

* It does not see errors that only happen in the browser (JavaScript).
* It does not charge a real card, so a payment provider's own outage is not caught.
* WooCommerce itself is tested but never rolled back, because its updates change the database. You get an email instead.
* Rollback puts back the plugin or theme files, not the database.
* WordPress core and translation updates are not touched.

Free, no account, no outside service: everything runs on your own store.

== Installation ==

1. Make sure WooCommerce is installed and active.
2. Under Plugins > Add New, search for "Tadrik Safe Updates", then install and activate it. Or upload the zip under Plugins > Add New > Upload Plugin.
3. Open WooCommerce > Safe Updates and press "Run a test now". All checks should pass; that test is what the next update is compared with.
4. Optional: under Settings, add the email addresses that should get alerts.

== Frequently Asked Questions ==

= Does it touch my real orders or send emails to customers? =

No. The test order is marked as a test, paid with a test method that takes no money, and deleted seconds later. While the test runs, the store sends no email and no webhook for it. Your real orders are never read or changed.

= What if my host blocks the store from loading its own pages? =

Then the test can't run. Nothing is rolled back, and you get an email saying the update could not be tested. "Run a test now" shows which step failed. Password-protected staging sites behave the same way.

= Does it work with the block checkout? =

Yes. The test order goes through the Store API, which is what the checkout block uses. The classic checkout works too.

= What happens when a WooCommerce update breaks checkout? =

You get an email right away. WooCommerce itself is not rolled back, because its updates change the database and old files over a newer database can break more than they fix.

= Where are the copies kept? =

In wp-content/tadrik-safe-updates/, as zip files with random names, guarded against direct access. A copy is deleted once the update passes its test, or once it has been put back.

= What if a copy can't be saved before an update? =

By default the update is stopped and nothing changes, so an update never runs without a way back. You can turn that off under Settings.

= What happens if I delete the plugin? =

Its settings, log, copies and the hidden test item are removed. Your orders and products are not touched.

== Screenshots ==

1. Status: the last checkout test, check by check, and the update log.
2. An update that broke checkout, rolled back, with the email that went out.
3. Settings: alert emails, daily test, and what happens when no copy can be saved.

== External services ==

This plugin doesn't connect to any outside service. The checkout test is a set of requests from your store to itself.

== Changelog ==

= 0.1.0 =
* First version: a copy before each plugin and theme update, a test order through checkout after it, rollback and an email when checkout broke, held-back versions, a daily checkout test.
