Freebie Condition: LevelFormula__c Field Specification

Available for instances with the enabled Web Service.

Level Formula allows adding freebies based not only on the number of products, but also on the product amount. Also, the required quantity can be calculated using constants or additional fields, such as the Freebie Value field.

Examples

Example of complex calculation:

{
    "operator": "sum",
    "items": [
        {
            "operator": "multi",
            "items": [
                "orders__QuantityFromPreviousOrders__c",
                "$.quantity"
            ]
        }
    ]
}

Example of a calculation with multiplication and minus:

{
    "operator": "multi",
    "items": [
        "$.quantity",
        "-orders__QuantityFromPreviousOrders__c",
    ]
}

Example of a calculation with division and cutDecimalsTo:

{
    "operator": "divide",
    "cutDecimalsTo"  : 0
    "items": [
        "$.totalPrice",
        300
    ]
}

JSON Key Description

Key Type Required Comment

cutDecimalsTo

Number

No

The optional operator 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

Is used in calculations.

  • Fields on following objects:

    • Order Line item

  • A constant value.

  • Fields on related objects, for example, ProductId__r.Weight__c.

  • The following fields specified in the CT Orders settings in the format:

    • $.listPrice

    • $.quantity

    • $.unitPrice

    • $.totalPrice

    • $.totalDiscount

operator

Enum

Yes

The arithmetic operation:

  • sum is addition

  • multi is multiplication. Multiplication by 0 will result in 0.

  • minus is substraction.

    It is possible to use the minus sign, for example, -$.quantity . The minus sign is considered in the calculations.
  • divide is division. Division by 0 will result in 0.

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.

``