Order Trail for WooCommerce releases
WooCommerce plugin that makes the entire order lifecycle auditable by logging every order edit to order notes
by Robot of the Future · github.com/mjoslyn/order-trail-for-woocommerce · website
Install
The author publishes release zips, so WP-CLI can install straight from GitHub:
wp plugin install https://github.com/mjoslyn/order-trail-for-woocommerce/releases/download/v2.0.0/order-trail-for-woocommerce-v2.0.0.zipMakes the entire order lifecycle auditable by writing an order note for every order edit, attributed to the user (or system process) that made it.
What gets logged
Every note ends with [by username] (or WP-CLI, WP-Cron, system). Notes carry no prefix by default; use the order_trail_note_prefix filter to add a marker such as [Audit].
- Items added/removed — products, fees, shipping lines, with quantities and amounts
- Coupons applied and removed, with discount amounts
- Item edits in the admin — quantity, subtotal, line total, fee names, shipping cost/label, shown as
old -> new(catches manual price-edit discounts) - Order field changes — totals, addresses, payment method, transaction ID, customer, dates, diffed against the database right before save
- Refunds — creation (amount, reason, gateway vs manual, restock) and deletion
- Order emails sent or failed through the WooCommerce mailer
New orders created during checkout are suppressed so a fresh order does not get flooded with "item added" notes. Tax-line recalculation churn and internal bookkeeping props are filtered out. Compatible with HPOS and legacy post storage.
Installation
Copy the order-trail-for-woocommerce folder into wp-content/plugins/ and activate. No settings screen; logging starts immediately.
Extending
Write your own audit notes with the standard prefix and actor attribution:
do_action( 'order_trail', $order_id, 'Something happened' );
| Hook | Type | Purpose |
|---|---|---|
order_trail |
action | Write a custom audit note through the plugin |
order_trail_note_prefix |
filter | Prepend a marker such as [Audit] to every note (empty by default) |
order_trail_ignored_props |
filter | Add/remove order props excluded from change logging |
order_trail_watched_meta |
filter | Opt in order meta keys to diff and log on save (empty by default); map key => label for readable note text |
order_trail_email_notes |
filter | Return false to disable built-in email notes (e.g. when your own email logger writes richer notes via the action above) |
order_trail_email_note |
filter | Filter the email note text |
Testing
Integration tests run in wp-env against a fresh WordPress + latest WooCommerce install (no mocks, no external site). Requires Docker and Node:
composer install
npm install
npm run env:start
npm test
npm run env:stop stops the containers; npm run env:destroy removes them entirely. CI runs the same setup on every push across a PHP version matrix (see .github/workflows/tests.yml).
The bootstrap is environment-agnostic: it boots whatever install WP_LOAD_PATH points at (defaulting to the one the plugin directory sits inside), so vendor/bin/phpunit also works directly against any WordPress install with WooCommerce active. As a safety measure it refuses to run unless the database name contains test (override with WP_TESTS_ALLOW_ANY_DB=1), and it defines PHPUNIT_TEST_MODE before loading WordPress so a wp-config.php can switch to a dedicated test database.
Known gaps
- Line-item meta edits are not diffed (too noisy to be useful).
- In-place item edits made via the REST API bypass the admin save hook; item adds/removes, refunds, and order field changes are still caught.
License
GPL-2.0-or-later
Releases
2 releases. Each count is every asset in that release; expand a row for the breakdown.