Order Discounts
Discounts are static monetary adjustments on an order. They represent fixed deductions — either a flat amount or a percentage — applied to the order total, individual order lines, native fulfillment shipping charges, or individual fees.
TIP
For dynamic, component-based pricing logic that re-evaluates as orders change, see Promotions.
Discount Types
Absolute
A fixed monetary amount deducted from the target. The value is treated as including or excluding tax based on the order's taxIncluded setting.
{
"type": "createStaticOrderDiscount",
"value": 50,
"description": "Loyalty reward"
}Percentage
A proportional deduction expressed as a factor. For example, 0.1 means 10% off.
{
"type": "createStaticOrderDiscount",
"isPercentage": true,
"value": 0.1,
"description": "10% staff discount"
}Discount Scopes
Static discounts can target different parts of an order:
Order Discount
Distributed proportionally across every active cost-bearing entity on the order — order lines, native fulfillment shipping charges, and fees. A 100% order discount reduces the active order total to zero. Created with createStaticOrderDiscount.
Order Line Discount
Applied to a specific order line. Created with createStaticOrderLineDiscount.
Shipping Discount
Applied to a fulfillment's native shipping charge. Created with createStaticShippingDiscount.
Managing Discounts
Creating
Use the appropriate command for the scope you need:
[{
"type": "applyCommands",
"body": {
"commands": [{
"type": "createStaticOrderDiscount",
"value": 50,
"description": "Coupon ABC123"
}]
}
}]An optional discountId can be provided. If omitted, one is generated automatically.
Updating
Change the value of an existing static discount with setStaticDiscountValue:
{
"type": "setStaticDiscountValue",
"discountId": "65812410-bd14-4d6d-ab79-374789a976c1",
"value": 75
}Metadata
setDiscountDescription— update the customer-facing descriptionsetDiscountDynamicFields— store custom metadata
Deleting
Remove a discount with deleteDiscount:
{
"type": "deleteDiscount",
"discountId": "65812410-bd14-4d6d-ab79-374789a976c1"
}Calculated Discounts
When a discount is applied, the system calculates the actual monetary impact and distributes it across order lines and shipping as CalculatedDiscounts. These represent the resolved per-line or per-shipping amounts in the order's currency.
Calculated discounts are allocation facts. In addition to the source reference and value, they snapshot the resolved label and dynamic metadata used for display and reporting. Static discounts automatically forward their description and dynamic fields to every calculated discount they create.
Promotions can additionally use a group wrapper to create separately attributable allocations from one promotion. Those calculated discounts carry the group's optional groupKey, label, and dynamic metadata. This makes it possible to query actual granted discount amounts by campaign without reconstructing the promotion calculation.
You can query calculated discounts through the Graph:
discount— the discount entity itselfcalculatedDiscount— the resolved amounts per order line / shipping
See Also
- Promotions — dynamic, component-based discount logic
- Order Commands — full command reference
- Order Actor — order actor overview