WooCommerce coupon rules
Advanced conditions around the coupon you already have.
PerkRule is designed to add rule-driven eligibility to native WooCommerce coupons instead of moving promotions into a separate proprietary rule database.
CONDITIONS
Evaluate the cart, customer and checkout context.
Core rule types cover cart subtotal, quantity, item count, applied coupons, login state, customer roles, billing and shipping geography, payment methods and shipping methods.
WHAT CAN BECOME A FACT
Rules evaluate a request-scoped snapshot of the cart, customer and checkout rather than reaching into WordPress whenever they feel like it.
The context can contain facts such as subtotal, quantity, line count, already-applied coupon codes, login state, roles, billing and shipping geography, payment method and shipping methods. The factory captures those values once for an evaluation snapshot and the rule engine consumes immutable value objects. Evaluators do not query the database, mutate the cart, call remote services or perform enrichment while deciding whether a rule matches.
ABSENCE IS A REAL STATE
Missing checkout information does not magically become a positive match.
Optional facts can be unavailable early in the cart lifecycle. PerkRule treats an absent fact conservatively: it produces no-match even for a negative comparison such as 'not equal', because not knowing a value is not evidence that the value differs. Guest roles and absent shipping methods use explicit empty sets so set-based rules behave consistently. This avoids promotions appearing merely because checkout has not collected enough information yet.
GROUPS
Combine rules without making evaluation ambiguous.
Rule groups support explicit ALL and ANY semantics. Invalid or unknown rule definitions fail closed where they need to, rather than silently granting a promotion.
ALL / ANY SEMANTICS
Groups have explicit behavior, including the awkward empty and invalid cases.
ALL can short-circuit on the first definite no-match. ANY is intentionally more conservative: after finding a matching child it still checks remaining children so a later invalid definition cannot be hidden and accidentally grant a promotion. An empty ALL represents no additional restriction and matches; an empty ANY does not. Unknown rule types, malformed values and invalid children produce safe failures instead of silently turning broken configuration into a discount.
STRUCTURAL LIMITS
A rule tree is data, but it is still untrusted input with hard complexity limits.
Definitions use versioned transparent JSON and are compiled into a deterministic structural representation. Document size, tree depth, total node count, identifier length and encoded rule-value size are bounded before runtime evaluation. Cached compiled envelopes are also revalidated against their source fingerprint. The compiler never embeds a cart, customer, session, timestamp or live WC_Coupon object, keeping reusable structure separate from request-specific facts.
NATIVE VALIDATION
PerkRule vetoes; WooCommerce remains authoritative.
The validation bridge preserves native WooCommerce decisions and only adds PerkRule restrictions. A rule match does not bypass native coupon restrictions.
NATIVE FIRST
PerkRule can make a valid WooCommerce coupon unavailable, but it cannot resurrect one WooCommerce has rejected.
The integration attaches to WooCommerce's server-side coupon-validity boundary. If WooCommerce has already returned false, PerkRule returns immediately without compiling rules or building a context. Native existence, status, expiry, usage limits, product restrictions, individual-use behavior and discount arithmetic therefore remain authoritative. PerkRule adds a second eligibility gate; it does not replace the first one or reinterpret native failures as permission to continue.
SELF-REFERENCE PROTECTION
The coupon being validated is removed from its own applied-coupon view before PerkRule rules are evaluated.
WooCommerce may validate a coupon during first application and later revalidate it while that same code already appears in the cart. Without a subject-excluded projection, a rule such as 'coupon X is already applied' could accidentally become true only because coupon X is validating itself. PerkRule builds an immutable projection that excludes the normalized subject code while keeping every other applied coupon. The live cart and original context are not changed.
SAFE FAILURE
A broken PerkRule rule vetoes only the subject promotion; it does not fatal checkout or leak internal diagnostics to the shopper.
No-match, invalid definitions, unknown rules and bounded runtime failures make that coupon unavailable. PerkRule-originated validation errors map to a generic customer-facing message rather than exposing rule values or customer diagnostics. The integration does not recursively apply coupons, remove coupons or trigger totals calculation while validating. Repeated checks are designed to remain deterministic and side-effect free.
See the full promotion model.
Rules are one part of Product 001 alongside Auto Apply and deterministic conflict handling.
Explore Product 001PerkRule support room
Real support works better when people can talk.
The PerkRule Discord will be the direct place for setup questions, bug reports, compatibility notes and release discussion. Useful answers should not disappear into private tickets — recurring problems can become documentation and Engineering Notes.
Discord opens around Product 001 release