Azwar's Portfolio
StockLatch ā On-Hold Order & Stock Manager for WooCommerce
September 23, 2026 (3w ago)

š About Project
š StockLatch is a free WooCommerce plugin I built and published on the official WordPress.org plugin directory to solve a subtle inventory problem: WooCommerce's built-in Hold stock (minutes) setting expires pending-payment orders, but ordinary On hold orders can continue reserving stock indefinitely.
That becomes a real issue for stores accepting Direct Bank Transfer (BACS), cheque, or other offline payment methods. If a customer never completes payment, the order remains on hold and its items stay unavailable until a store manager notices and manually cancels it. StockLatch closes that gap by monitoring selected payment gateways and cancelling an unpaid on-hold order only after its configured reservation deadline has passed.
The plugin deliberately never edits product quantities itself. It changes the expired order's status to Cancelled, allowing WooCommerce's own stock-restoration workflow to return exactly the inventory that WooCommerce originally reduced. This avoids double restoration, respects WooCommerce filters, and remains compatible with other extensions that participate in the order lifecycle.
Each monitored order receives one scheduled deadline check through WooCommerce's bundled Action Scheduler. When that job runs, StockLatch re-validates every safety condition: the plugin must still be enabled, the order must exist, remain unpaid and on hold, use a selected gateway, and have actually passed its deadline. If a customer pays or an administrator changes the status first, the lifecycle is closed and the cancellation is skipped.
StockLatch also includes an operational dashboard, a filterable activity log, internal order notes, and a confirmation-gated tool for importing orders that were already on hold before installation. It supports WooCommerce High-Performance Order Storage (HPOS), uses WooCommerce CRUD APIs instead of querying order tables directly, and makes no external requests or telemetry calls.
⨠Features
ā±ļø Safe Order Expiration
- Automatic cancellation of expired, unpaid on-hold orders
- Gateway selection for BACS, cheque, or any other configured WooCommerce payment method
- Flexible timeout in minutes, hours, or days, with a 48-hour default
- One scheduled check per order through WooCommerce Action Scheduler
- Last-moment validation before any cancellation is allowed
š¦ Inventory Protection
- No direct stock edits ā WooCommerce performs its normal stock restoration after cancellation
- No double restoration ā duplicated or replayed jobs are safe to run
- Payment-aware lifecycle ā paid orders and orders moved out of On hold are never cancelled
- Gateway deselection as a brake ā queued orders are skipped if their gateway is no longer monitored
- HPOS compatible through WooCommerce CRUD and query APIs
š Visibility and Control
- Dashboard metrics for monitored orders, held units, upcoming expirations, and recent results
- Filterable activity log showing scheduled, paid, skipped, superseded, and cancelled outcomes
- Internal order notes when monitoring starts and when an expired order is cancelled
- Existing-order import tool with a preview and explicit confirmation
- Fresh timeout on import, preventing old orders from being cancelled immediately
š Privacy and Reliability
- Disabled on installation until a store administrator explicitly configures and enables it
- No external requests, telemetry, licensing calls, or customer-data collection
- Atomic lifecycle claims to make scheduled processing idempotent
- Clean deactivation that disables monitoring and removes queued jobs
- Optional data deletion on uninstall, disabled by default
š ļø Technology Stack
- Platform: WordPress 6.5+, WooCommerce 8.2+, PHP 7.4+
- Architecture: Namespaced, class-based PHP with dedicated lifecycle, settings, scheduling, logging, and admin layers
- Scheduling: WooCommerce Action Scheduler with one deadline job per monitored order
- Data: WooCommerce CRUD APIs plus a dedicated activity table containing operational metadata only
- Compatibility: WooCommerce High-Performance Order Storage (HPOS)
- Admin UI: Native WordPress components with lightweight JavaScript and CSS
- Quality: PHPUnit, Brain Monkey, PHPCS, WordPress Coding Standards, and PHPCompatibility
- Distribution: Reviewed and published on WordPress.org under GPL-2.0-or-later
š² Contact Info
š© E-mail: r.azwar42@gmail.com
š§³ Linkedin: Rao Azwar Lin
šØš»āš» GitHub: Rao Azwar
Made with š¤ by @raoazwar