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
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 integer number 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 actions page):
type
Must be "fixed_amount"
.
selector
identifier
Can be set only if the selector
key value is an attribute.
groups
bundle
aggregation
apply_on
discount_mode
limit
value
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:
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
Considering the example above, let's assume that the two targeted groups contain the following items:
The group labeled as default-discount
contains 2 line items for a total of 3 units and 22000 cents total amount:
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 a900 / 2 = 450
unit discount.ITEMDIS02
—6000 * 0.75 = 4500
cents of total discount, corresponding to a900 / 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
Fixed amount actions support bundles, 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 discount mode different from the default is available for fixed amount actions only.
You can set a limit on fixed amount actions only if you're not using bundles.
Resources
As regards the Rule Engine integration with Commerce Layer Core API, the fixed amount action type is available both for promotions (order rules) and price lists (price rules).
Last updated