WordPress & web · shop.checkoutCI passing
WooCommerce Pricing Rules
Bulk, tiered, BOGO and cart discounts that match an independent reference to the cent.
View the code Evaluation report Demo tour Run it ›_ last push 5 days ago
0 / 20,000random carts that differ from the independent reference
10 / 10planted bugs caught by the tests (mutation testing)
2.6 msp95 for a 50-line, 50,000-unit cart (reference: about 2 s)
demo Demo tour
Screenshots from the running application, with its synthetic demo data. Select one to enlarge.
01 The problem
Discount plugins compute prices with floating point and stack percentages by adding them, so carts drift by pennies or go below zero, and big orders slow the checkout down.
02 How it works
- Cart lines
- Matching rules (schedule, role, category)
- Units grouped into buckets
- Integer-cent discounts
- Price floor
- WooCommerce totals
03 What I built
- A pricing engine in integer cents with rule types for bulk tiers, buy-x-get-y, category and cart discounts, schedules, customer roles and a price floor.
- Property tests against a separately written unit-by-unit reference, plus mutation testing to prove those tests catch planted bugs.
- An admin rule editor, cart and product-page badges, and integration tests in real WooCommerce 9.9 and 11.2.
04 What I learned
The first reference shared helpers with the engine, so mutants survived; an independent reference plus boundary cases caught all ten.
Two of my hand-written expected totals were wrong and the engine was right, which is why the comparison is with code, not with my arithmetic.
05 Known limitations
Every repository documents what it doesn't do yet. The main ones:
- Rules are evaluated per cart; there is no coupon-code integration beyond WooCommerce's own.
- Tested with WooCommerce 9.9 to 11.2.
06 Stack
PHP 8.1WooCommerceWordPressPHPUnitPHPStanProperty testing
The repository has the design document, operations runbook, full evaluation report and known limitations. All data is synthetic, generated by code in the repository.
run Run it yourself
Every project runs on a laptop: no cloud account and no paid API needed.
git clone https://github.com/codeROCK-IZZY/woocommerce-pricing-rules.git
cd woocommerce-pricing-rules
composer install && vendor/bin/phpunit
php eval/run.php --gate # writes eval/reports/report.html



