Promotions Architecture & Specs

A robust rules engine built to evaluate complex cart adjustments with sub-5ms latency and mathematically strict stacking hierarchies.

Evaluation & Processing Metrics

Cart Evaluation Latency

< 5ms

Active Promotions Evaluated Per Cart

up to 100, highest priority first

Bulk Code Generation

up to 10,000 codes per request

Usage-limit enforcement

Atomic database-level locking, re-checked at the moment of purchase

1. The Discount Evaluation Pipeline

The engine never overwrites your original product prices — it generates a transparent list of discount adjustments applied on top, so your accounting and reporting always have a clear record of exactly what was discounted and why. - Stacking Priorities: Promotions are evaluated in priority order, highest first. Once a non-stackable promotion is applied to a cart, the engine stops evaluating any other non-stackable promotions for that cart — preventing accidental over-discounting. - Exclusion Rules: Any promotion can be configured to explicitly block specific other promotions. Before calculating a discount, the engine checks that exclusion list against everything already applied to the cart, physically preventing conflicting discounts from stacking together.

2. Advanced Mathematical Calculations

The engine supports complex computational vectors out of the box. - Cross-Product Volume Bundles: Handles scenarios like "Buy 5+ items from any combination of Categories A, B, and C." The engine matches cart items against your configured bundle groups and applies the discount to all eligible items by default — or, if configured, just the cheapest item, just the most expensive item, or only the items beyond the minimum threshold — with no custom code required. - BOGO Optimization: For "Buy X Get Y" logic, the engine sorts items by price so the customer receives the cheapest qualifying item for free, protecting the merchant's margin natively without requiring custom code.

Engine FAQ

No. The engine never mutates your catalog prices. It emits a separate, itemized list of adjustments layered on top of the cart, so your product records and accounting keep the original price while reporting sees exactly what was discounted and why.

Usage limits are enforced atomically at the database level and re-checked at the moment of purchase. If concurrent checkouts would push redemptions past the cap, the surplus is rejected with a clear sold-out response instead of overshooting the limit — no race-condition over-redemption, no negative-margin exploit.

Promotions evaluate in priority order, highest first. Once a non-stackable promotion applies, the engine stops considering other non-stackable ones for that cart. Any promotion can also declare an explicit exclusion list, which is checked against everything already on the cart before a discount is calculated.

For Buy-X-Get-Y logic it sorts qualifying items by price and discounts the cheapest, protecting your margin by default — no custom code required. Cross-product volume bundles can instead be configured to target only the most expensive item, or only the items beyond the minimum threshold.

Native Commerce sync restores it. Promo usage increments when an order completes and is safely returned if that order is later refunded, so a cancelled sale doesn't permanently consume a limited-use code.

Composes with the rest of the OS

See the promotion engine in action