Need to create rules based on bundles?
Learn more
LogoLogo
APIsChangelog
  • Getting started
  • Rules
  • Conditions
    • Scope
    • Aggregations
    • Nested
    • Dynamic values
  • Actions
    • Types
      • Percentage
      • Fixed amount
      • Fixed price
      • Buy X pay Y
      • Every X discount Y
    • Bundle
      • Balanced
      • Every
    • Aggregation
    • Limit
  • Matchers
  • Operators
  • Check and validation
  • Core API integration
    • Order rules
    • Price rules
    • Virtual relationships
  • Resources
    • Promotions
    • Price lists
  • Use cases
    • Promotions
      • Discount line items based on item's price
      • Get a discount when paying by credit card
      • Discount an order based on promo item and total number of items
      • Offer a specific shipping method for free in a specific country
      • Discount items with large stock availability
      • Discount all the SKU in an order based on the shipping country
      • Discount all the SKU in an order based on the customer email domain
    • Price lists
      • Discount all prices greater than or equal to a specific value
      • Discount specific SKUs for new clients
      • Change strike-through price based on customer email domain
On this page
  • Example
  • Value
  • Discount mode
  • Example
  • Restrictions
  • Resources
  1. Actions
  2. Types

Fixed amount

How the fixed amount discount action works, what are the required and optional parameters to set it up, and the resources for which it's enabled

PreviousPercentageNextFixed price

Last updated 2 months ago

Actions of type fixed_amount enable you to apply a a fixed discount to the unit amount of a specific field.

When setting up a fixed amount action, in addition to the action type, you need to specify at least the attribute or resource on which to apply the action as the selector key value and fill the value key with the corresponding to the amount in cents to be discounted (for more information on the parameters listed in the table below and how they work please refer to the main ):

Key
Type
Required
Notes

type

String

Must be "fixed_amount".

selector

String

identifier

String

Can be set only if the selector key value is an attribute.

groups

Array

bundle

Object

aggregation

Object

apply_on

String

discount_mode

String

limit

Object

value

Integer

Example

The following action applies a 2000 cents fixed discount to the unit amount of all the line items associated with an SKU among the ones grouped as default-discount within the related condition matchers and distributes a 6000 cents discount over all the line items associated with an SKU among the ones grouped as distributed-discount within the related condition matchers:

"actions": [
  {
    "type": "fixed_amount",
    "selector": "order.line_items.sku",
    "groups": [ "default-discount" ],
    "value": 2000,  
  },
  {
    "type": "fixed_amount",
    "selector": "order.line_items.sku",
    "discount_mode": "distributed",
    "groups": [ "distributed-discount" ],
    "value": 10000,  
  }
]

Value

The amount to be discounted is defined by the value key which must be provided in cents (e.g. 1500 applied to an order with currency code EUR corresponds to a 15€ discount).

Discount mode

By default fixed amount actions use the number specified in the value key as the fixed amount in cents to be discounted from the unit amount of each selected item. You can override this behavior by setting the discount_mode key to distributed. This way the amount to be discounted will be proportionally distributed on the targeted items based on their total amount (i.e. taking into account their unit amount and quantity).

Example

The group labeled as default-discount contains 2 line items for a total of 3 units and 22000 cents total amount:

[
  {
    "id": "mnptRLjoXJ",
    "type": "line_items",
    "quantity": 1,
    "unit_amount_cents": 10000,
    "total_amount_cents": 10000,
    "sku": {
      "id": "zTdkkFXdgN",
      "code": "ITEMDEF01"
    }
  },
  {
    "id": "jndtDLsoAM",
    "type": "line_items",
    "quantity": 2,
    "unit_amount_cents": 6000,
    "total_amount_cents": 12000,
    "sku": {
      "id": "xCKdTcQFQH",
      "code": "ITEMDEF02"
    }
  }
]

The group labeled as distributed-discount contains 3 line items for a total of 6 units and 20000 cents total amount:

[
  {
    "id": "qOYocnANsO",
    "type": "line_items",
    "quantity": 2,
    "unit_amount_cents": 1500,
    "total_amount_cents": 3000,
    "sku": {
      "id": "PeHfayCvwQ",
      "code": "ITEMDIS01"
    }
  },
  {
    "id": "nlHjpkVpCG",
    "type": "line_items",
    "quantity": 3,
    "unit_amount_cents": 5000,
    "total_amount_cents": 15000,
    "sku": {
      "id": "pHaoUAvTVy",
      "code": "ITEMDIS02"
    }
  },
  {
    "id": "DtZjSMEKvm",
    "type": "line_items",
    "quantity": 1,
    "unit_amount_cents": 2000,
    "total_amount_cents": 2000,
    "sku": {
      "id": "TkhHRotCOA",
      "code": "ITEMDIS03"
    }
  }
]

The discount for each item will be computed as follows:

Default

A fixed amount discount of 2000 cents will be applied to each item's unit amount, corresponding to:

  • ITEMDEF01 — 2000 * 1 = 2000 cents total discount.

  • ITEMDEF02 — 2000 * 2 = 4000 cents total discount.

Distributed

As a first step, the weight of each item's total amount compared to the sum of the total amounts of all the targeted items (20000 cents) is calculated:

  • ITEMDIS01 — 3000 / 20000 = 0.15

  • ITEMDIS02 — 15000 / 20000 = 0.75

  • ITEMDIS03 — 2000 / 20000 = 0.1

As you may expect, the total sum of those weights is 0.15 + 0.75 + 0.1. = 1 .

Then the unit and total discount to apply to each item is computed based on that, proportionally distributing the number specified in the value key of the action (6000):

  • ITEMDIS01 — 6000 * 0.15 = 900 cents of total discount, corresponding to a 900 / 2 = 450 unit discount.

  • ITEMDIS02 — 6000 * 0.75 = 4500 cents of total discount, corresponding to a 900 / 3 = 1500 unit discount.

  • ITEMDIS03 — 6000 * 0.1 = 600 cents of total discount, corresponding to the same unit discount since the item's quantity is 1.

As you may expect, the total sum of those discounts is 900 + 4500 + 600 = 6000 (i.e. the total discount to be distributed over the targeted items). Being the results of the divisions cut at the second decimal, this may not always be true. If that's the case an additional ± rounding on the second decimal of the unit discount applied to the targeted item with less quantity will be automatically applied to match the total discount to be distributed.

Restrictions

Resources

Required when using .

Learn more .

Cannot be set when using .

Considering the above, let's assume that the two targeted groups contain the following items:

Fixed amount actions support , provided that one or more groups among the ones defined when grouping the matches of the related conditions are specified. The possibility to set a different from the default is available for fixed amount actions only.

You can set a on fixed amount actions only if you're not using bundles.

As regards the Rule Engine , the fixed amount action type is available both for () and ().

limit
actions page
integer number
example
bundles
discount mode
bundles
bundles
here
promotions
order rules
price lists
price rules
integration with Commerce Layer Core API