Calculation Type: LevelFormula__c Field Specification
Level Formula allows specifying a formula for calculating product quantity, based on which the discount will be calculated.
Level Formula is also available for freebies. For more information, refer to Freebie Condition: LevelFormula__c Field Specification.
Examples
The formula performs calculations in fields based on the object set in the Level Based On field.
Example of a complex calculation of quantity using addition and multiplication on several levels:
{
"operator": "sum",
"items": [3,
{
"operator": "multi",
"items": [
"orders__QuantityFromPreviousOrders__c",
"$.quantity"
]
}
]
}
Example of a calculation with addition and roundTo:
{
"operator": "sum",
"roundTo" : 2
"items": [
"orders__QuantityFromPreviousOrders__c",
"$.quantity"
]
}
Example of a calculation with division and cutDecimalsTo:
{
"operator": "divide",
"cutDecimalsTo" : 0
"items": [
"$.totalPrice",
300
]
}
Example of a calculation with multiplication and minus:
{
"operator": "multi",
"items": [
"$.quantity",
"-orders__QuantityFromPreviousOrders__c",
]
}
JSON Key Description
| Key | Type | Required | Comment | ||
|---|---|---|---|---|---|
cutDecimalsTo |
Number |
No |
The optional operator that truncates the number of the decimal places on the resulting value after the operations with items. It can be used in pair with roundTo after rounding. |
||
items |
Array |
Yes |
Items to be used in calculations.
|
||
operator |
Enum |
Yes |
The arithmetic operation:
|
||
roundTo |
Number |
No |
The optional and rounds the number of decimals on the resulting value after the operations with items. It can be used in pair with cutDecimalsTo before truncating to the required number of decimal places. |