Skip to content

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, or shipping 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.

json
{
  "type": "createStaticOrderDiscount",
  "value": 50,
  "description": "Loyalty reward"
}

Percentage

A proportional deduction expressed as a factor. For example, 0.1 means 10% off.

json
{
  "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 all order lines and shipping fees. Created with createStaticOrderDiscount.

Order Line Discount

Applied to a specific order line. Created with createStaticOrderLineDiscount.

Shipping Discount

Applied to a delivery's shipping fee. Created with createStaticShippingDiscount.

Managing Discounts

Creating

Use the appropriate command for the scope you need:

json
[{
  "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:

json
{
  "type": "setStaticDiscountValue",
  "discountId": "65812410-bd14-4d6d-ab79-374789a976c1",
  "value": 75
}

Metadata

Deleting

Remove a discount with deleteDiscount:

json
{
  "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.

You can query calculated discounts through the Graph:

See Also

© 2024 Hantera AB. All rights reserved.