WP Manifestindependent plugin directory
manifest / ecommerce / wc-stale-order-guard

WooCommerce Stale Order Guard

HPOS-compatible WooCommerce plugin that flags orders stuck in a status too long and emails a digest. Action Scheduler + WP-CLI. By CodeCollab.pl

by CodeCollab.pl (Krystian Kacik) · github.com/krystian-kacik-fullstack-codecollab-pl/wc-stale-order-guard · website

0stars
0forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/krystian-kacik-fullstack-codecollab-pl/wc-stale-order-guard/archive/refs/heads/main.zip

Readme

WooCommerce Stale Order Guard

Orders quietly rot. A payment lands, the order moves to processing, and then nobody touches it for two weeks because it slipped off the first page of the admin. Stale Order Guard watches the order statuses you care about and emails the team a digest of anything that has been sitting still for too long.

It is small on purpose - one job, done cleanly - and it is built the way a production WooCommerce extension should be: HPOS-compatible, driven by Action Scheduler, scriptable through WP-CLI, and covered by tests in CI.

Features

  • Scheduled scan of configurable order statuses via Action Scheduler (not WP-Cron).
  • HPOS-compatible - uses wc_get_orders() only, so it works on both custom order tables and the legacy posts store.
  • E-mail digest to the team with a direct edit link per order.
  • WP-CLI command for on-demand scans and scripting.
  • Native settings UI under WooCommerce → Settings → Advanced → Stale Orders.
  • Self-healing schedule - the recurring action is re-asserted on admin load.

Requirements

PHP 8.1+
WordPress 6.4+
WooCommerce 8.2+

Installation

# From source
git clone https://github.com/krystian-kacik-fullstack-codecollab-pl/wc-stale-order-guard.git
cd wc-stale-order-guard
composer install --no-dev

Copy the folder into wp-content/plugins/ and activate it from the WordPress admin, or via WP-CLI:

wp plugin activate wc-stale-order-guard

Configuration

WooCommerce → Settings → Advanced → Stale Orders

Setting Default Description
Enable scheduled scan on Toggles the recurring Action Scheduler job.
Stale after (days) 7 Days an order may sit untouched before it is flagged.
Digest recipient site admin Where the digest is sent. Empty falls back to the admin e-mail.

WP-CLI

# Print stale orders as a table
wp stale-orders scan

# Scan and also send the digest e-mail
wp stale-orders scan --send

# Pipe stale order IDs into another command
wp stale-orders scan --format=ids

Hooks

// Change how often the scan runs (default: every 12 hours).
add_filter( 'wc_stale_order_guard_scan_interval', static fn () => 6 * HOUR_IN_SECONDS );

Architecture

The business rule lives in a dependency-free value object so it can be tested without bootstrapping WordPress:

src/
├── Plugin.php                      Composition root + WooCommerce guard
├── Settings.php                    Typed, validated access to stored options
├── Support/StalenessPolicy.php     Pure "is this order stale?" rule (unit-tested)
├── Orders/StaleOrderScanner.php    HPOS-safe query via wc_get_orders()
├── Scheduling/RecurringScan.php    Action Scheduler registration + handler
├── Notifications/DigestMailer.php  Renders and sends the digest
├── Admin/SettingsTab.php           Native WooCommerce settings section
└── Cli/ScanCommand.php             `wp stale-orders scan`

Development

composer install
composer test    # PHPUnit
composer lint    # PHP_CodeSniffer (WordPress-Extra)

License

GPL-2.0-or-later © CodeCollab.pl (Krystian Kacik)

Maintained by CodeCollab.pl - senior fullstack studio for WordPress & WooCommerce. Not affiliated with "CodeCollab Pte. Ltd." (Singapore).

Read the full README on GitHub →