Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/arnoldwender/wm-wp-ethical-conversion-triggers/archive/refs/heads/main.zipOrder and low-stock notices for WooCommerce product pages, shown only when the number is real and verifiable from HPOS order lookup tables and WooCommerce-managed inventory
Plugin page: https://arnoldwender.com/wordpress-plugins/wm-ethical-conversion-triggers/
Built with an agentic workflow: developed with AI coding agents. Review and test it like any third-party code before you use it in production.
Support & Liability: Zero support — reproducible bugs on GitHub Issues only · no private support · AS IS / no liability (SUPPORT.md)
Screenshots
!WM Ethical Conversion Triggers banner
| Settings > Ethical Triggers | WooCommerce Product Page |
|---|---|
![]() |
![]() |
What the plugin does
Two notices on WooCommerce product pages (woocommerce_before_add_to_cart_form), each gated by a strict condition:
| Notice | Shown only when |
|---|---|
| "%d Bestellung(en) dieses Artikels in den letzten 7 Tagen." | N > 0: distinct paid orders (wc_get_is_paid_statuses(), processing and completed by default) containing the product over the last 7 days, excluding refunds (stats.parent_id = 0), queried via prepared SQL from {prefix}wc_order_product_lookup and {prefix}wc_order_stats (HPOS compatible, no postmeta) |
| "Nur noch %d Stück auf Lager." | WooCommerce manages stock for that product (get_manage_stock()) and 1 <= stock <= threshold (5 by default, configurable 1..50 via filter) |
When neither condition holds, nothing is emitted — not even <div class="wm-ect-container" aria-live="polite" role="status">. An empty live region is still announced by screen readers, so the render guard in Frontend::render_ethical_trigger() is the exact negation of what is rendered.
Why scarcity is shown only with managed stock
If a product does not have stock management enabled in WooCommerce, there is no verifiable warehouse quantity. In that case Stock_Verifier::get_verified_stock() returns null (never 0 or a fallback value) and the low-stock line is omitted. Inventing urgency or stock counts constitutes unfair competition in regulated markets such as Germany (UWG § 5).
Languages included
languages/ ships wm-ethical-conversion-triggers.pot synchronized with the PHP source strings and 28 compiled gettext catalogs (.po and .mo): ar, bg_BG, cs_CZ, da_DK, de_DE, el, en_GB, en_US, es_ES, et, fi, fi_FI, fr_FR, ga, hr_HR, hu_HU, it_IT, lt_LT, lv, mt_MT, nl_NL, pl_PL, pt_PT, ro_RO, sk_SK, sl_SI, sv_SE, and tr_TR.
Requirements
- WordPress 6.0 or higher
- PHP 8.0 or higher (
declare(strict_types=1);across all PHP files) - WooCommerce active (declares HPOS / High-Performance Order Storage compatibility via
FeaturesUtil::declare_compatibility( 'custom_order_tables', ... )). The plugin header declaresRequires Plugins: woocommerce; without theWooCommerceclass loaded,Plugin::woocommerce_active()registers only an administrative error notice and guardsis_product()/wc_get_product()calls behindfunction_exists.
Installation & Opt-in Uninstall (D-UNINSTALL)
- Copy
wm-ethical-conversion-triggers/intowp-content/plugins/(with WooCommerce active). - Activate the plugin under Plugins. Product notices inject automatically at
woocommerce_before_add_to_cart_form. - Under Settings > Ethical Triggers (
options-general.php?page=wm-ethical-conversion-triggers, capabilitymanage_options), the optional checkboxwm_ethical_triggers_delete_data_on_uninstalldefaults to'0'. On plugin deletion,uninstall.phppreserves plugin options and cached order-count transients unless the administrator explicitly opts into deletion.
Extensibility & Integrations (includes/class-integrations.php)
- Developer hooks:
apply_filters( 'wm_ethical_triggers_config', array $config, int $product_id )— customizeslow_stock_threshold(1..50, default5),enable_sales_notice, andenable_stock_noticewithout relaxing the managed-stock or paid-order invariants.do_action( 'wm_ethical_triggers_ready', \WMEthicalConversionTriggers\Plugin $plugin )— fires oninitonce the plugin is initialized with WooCommerce active.do_action( 'wm_ethical_triggers_stock_updated', int $product_id, int $stock )— fires after the authenticated webhook updates a product's managed stock.
- WordPress 6.5+ Block Bindings: registers source
wm-ethical-triggers/metricsfor core blocks (key:summary,sales_notice, orstock_notice, plus optionalproduct_idorpostIdblock context). - GenerateBlocks 2.x Dynamic Tag: registers
{{wm_ethical_trigger}}viaGenerateBlocks_Register_Dynamic_Tag(field:summary,sales_notice, orstock_notice, with escaped output). - WM Suite Hub: spoke adapter registered through
wm_register_suite_module.
REST Webhook Endpoint
POST /wp-json/wm-ect/v1/stock-update
Updates a product's WooCommerce-managed stock from an external ERP or warehouse system (Webhook_Validator):
- Requires a base64-encoded HMAC-SHA256 signature in the
x-wc-webhook-signatureheader, compared in constant time viahash_equals(). - Reads the shared secret from the
WM_ECT_WEBHOOK_SECRETconstant (recommended inwp-config.php) or thewm_ect_webhook_secretoption. When no secret is configured, the endpoint returns HTTP500(missing_secret) and refuses every request. - JSON body:
{"product_id": <int>, "stock_quantity": <int>}. Invalid signatures return403, missing signatures401, missing WooCommerce501, and unknown products404.
Performance & Design Tokens
- Verified 7-day paid-order counts are cached per product in a 1-hour transient (
wm_ect_sales_<id>) and invalidated onwoocommerce_update_productand webhook stock updates. assets/css/ethical-triggers.cssdefines all visual properties as:rootCSS custom properties (--wm-ect-*) and loads only local plugin assets (Zero-CDN; no external requests).
Verification & Tests
php tests/test-suite.php
php tests/test-pot-freshness.php
bash tests/run-mutations.sh
python3 .github/scripts/security-audit.py
Structure
wm-ethical-conversion-triggers/
├── wm-ethical-conversion-triggers.php # header, HPOS declaration, constants, activation & boot
├── uninstall.php # opt-in cleanup on uninstall (D-UNINSTALL)
├── bom.json # CycloneDX 1.6 SBOM (GPL-2.0-or-later)
├── llms.txt # machine-readable plugin summary
├── includes/
│ ├── class-plugin.php # singleton, WooCommerce guard & hook wiring
│ ├── class-frontend.php # verified notice calculation & live-region guard
│ ├── class-stock-verifier.php # prepared HPOS order lookup & transient cache
│ ├── class-webhook-validator.php # wp-ect/v1/stock-update REST route & HMAC-SHA256 check
│ ├── class-settings.php # Settings > Ethical Triggers opt-in uninstall screen
│ └── class-integrations.php # WM Suite Hub spoke, Block Bindings & GenerateBlocks 2.x
├── assets/ # local Design-Token CSS (:root) and JS
├── languages/ # .pot template + 28 .po/.mo locale packs
├── tests/ # standalone suite, POT freshness & mutation checks
└── .github/workflows/ci.yml # CI matrix on PHP 8.0 / 8.2 / 8.3
License
Distributed under the GNU General Public License v2 or later (GPL-2.0-or-later). See LICENSE and the header of wm-ethical-conversion-triggers.php.

