Woo Custom Order Rules
Demo: upgrade-safe custom WooCommerce plugin — tiered & mix-and-match discounts, validated checkout field stored as order meta, order-status business logic. Documented hooks only, no custom tables, HPOS-compatible. Runs live in WordPress Playground.
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/cfconradie/woo-custom-order-rules/archive/refs/heads/main.zipA small, installable WooCommerce plugin that demonstrates the upgrade-safe way to add custom business logic to a store: documented hooks only, custom data stored as order and product meta (never a custom table), checkout fields added through the WooCommerce fields API with server-side validation (never template overrides), and behaviour driven off the order lifecycle. It is also HPOS-compatible (reads and writes order data through the CRUD API).
This is a portfolio demo — a clean reference implementation of the patterns I use for real custom WooCommerce work.
Live demo
Runs entirely in your browser via WordPress Playground (WordPress + WooCommerce + this plugin + a seeded catalogue, no install):
Log in at /wp-admin as admin / password. Add several bundle products to the cart to
watch the discounts apply, then place an order with a PO number and move it to Processing
to see the status-driven logic fire.
What it does
| # | Feature | Documented hook(s) | Storage |
|---|---|---|---|
| 1 | Tiered quantity discount (buy 5+ save 10%, 10+ save 15%) | woocommerce_before_calculate_totals |
— (runtime price) |
| 1 | Mix & Match bundle (any 10 group items = 15% off), shown on product + cart | woocommerce_cart_calculate_fees, woocommerce_single_product_summary, woocommerce_before_cart |
product meta _wcor_bundle_group |
| 2 | Validated PO-number checkout field, saved to the order | woocommerce_checkout_fields, woocommerce_checkout_process, woocommerce_checkout_create_order |
order meta _wcor_po_number |
| 3 | Flag PO / bundle-heavy orders for approval when they reach Processing | woocommerce_order_status_changed |
order meta _wcor_approval_required |
| — | Show the custom meta on the admin order screen | woocommerce_admin_order_data_after_billing_address |
reads order meta |
Why it stays upgrade-safe
- Documented action/filter hooks only — no core template overrides, no hooking of WooCommerce internals that shift between releases.
- Order and product meta, not custom tables — nothing to migrate, nothing that breaks when WooCommerce changes its schema.
- HPOS-declared — compatibility with High-Performance Order Storage is declared on
before_woocommerce_init, and all order data goes through the CRUD API ($order->get_meta()/update_meta_data()), neverget_post_metaon orders. - Isolated assets — the small notice stylesheet is enqueued only on WooCommerce pages.
Local development
Requires Docker. Uses @wordpress/env:
npx wp-env start # WordPress + WooCommerce + this plugin, all activated
bash bin/seed.sh # classic checkout + a seeded bundle catalogue
# store: http://localhost:8888 admin: http://localhost:8888/wp-admin (admin / password)
npx wp-env stop
Screenshots
See docs/ — product-page discount hint, cart with the Mix & Match line, the
checkout PO field, and the admin order screen with the approval flag + order note.
License
GPL-2.0-or-later.