feat(promotion): minimum purchase requirements and maximum discount amounts#16121
feat(promotion): minimum purchase requirements and maximum discount amounts#16121Ligament wants to merge 4 commits into
Conversation
…uirements on promotions Adds item_subtotal as a first-class promotion rule attribute with numeric operators (gte, gt, eq, lte, lt) so every promotion type can be gated on a minimum purchase amount, e.g. spend 100 or more to get a fixed discount, a percentage discount, a shipping discount, or free shipping. - Expose item_subtotal with numeric operators in the admin rule attribute options, and render number-valued rules in the promotion rules endpoints - Return a clean invalid_data error from rule-value-options for attributes without entity-backed value options - Type item_subtotal on ComputeActionContext - Include item_subtotal in the order edit / draft order promotion compute context so minimum purchase promotions survive order changes - Reset number rule values correctly in the dashboard rule form when switching operators Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Number-typed rule attributes (e.g. item_subtotal) now return a scalar value from GET /admin/promotions/:id/:rule_type, matching the disguised number rule convention the dashboard renders. Returning an array of value objects crashed the promotion detail page (objects are not valid as a React child). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…and fixed shipping discounts Adds max_amount to promotion application methods so percentage promotions can be capped at a fixed amount, e.g. 10% off up to a maximum of 50. - New nullable bigNumber max_amount column on promotion_application_method with migration - computeActions clamps item and shipping adjustments so a promotion's cumulative discount never exceeds max_amount - Validation: max_amount requires percentage type and a currency code, is not allowed for buyget promotions, and must be positive - Dashboard create flow exposes a Maximum Discount Amount input for percentage promotions and a new "Amount off shipping" template for fixed-amount shipping discounts Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: af7ce0b The changes in this PR will be included in the next version bump. This PR includes changesets to release 79 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Thanks for the contribution! A few items need to be addressed before this can move forward: Clean, well-tested feature adding an item_subtotal minimum-purchase rule attribute and a max_amount cap for percentage promotions (migration, types, dashboard, compute engine). Template is complete and tests are included. Two concerns before merge: (1) it's a large change (24 files, ~1150 lines) that adds a new DB column plus new public rule/API surface and touches the core promotion compute engine, with no linked pre-approved issue — large features should be scoped/aligned with the team first per CONTRIBUTING.md; (2) the order-edit item_subtotal derivation may resolve to 0 if previewed items
Triggered by: new PR opened |
…amount_off_shipping
What
Why
"Spend 100, get X" thresholds and capped percentage discounts are common merchant needs that currently require custom code. The compute engine already evaluates numeric rules against the cart context, but the admin rule options, dashboard, and order-edit contexts didn't expose them, and percentage discounts couldn't be capped.
How
Testing