Number Formatting

To format numbers on CrossEngage, you should use the formatDigits function. The syntax of this formatting function is:

{{formatDigits '{
    "propertyName": [Value that should be formatted], 
    "numberDecimals": [Decimals number],
    "decimalSeparator": [Decimal separator], 
    "thousandsSeparator": [Thousand separator],
    "percentage": [Percentage option]
    }'
}}

Please note that the formatDigits helper function only works when used with either the #includeProducts or #findProduct helper function.

Property

Type

Description

propertyName

string

Required. The attribute containing the value that is used for formatting. e.g. [properties.price]

numberDecimals

integer

Required. The number of decimals that is displayed. e.g. 2

decimalSeparator

string

Optional. The string that is used to separate decimals e.g. ,

thousandsSeparator

string

Optional. The string that is used to separate thousands e.g. .

percentage

boolean

Optional. This option specifies whether the value should be formatted as a percentage or not. e.g. true

Formatting the price of a product extracted from the product feed

Using the helper function #findProduct, we search for a particular sku and format the result's [properties.price] attribute. We use 2000 as the value of the product's price for the example below.

{{formatDigits '{
    "propertyName": "[properties.price]", 
    "numberDecimals": 2,
    "decimalSeparator": ",", 
    "thousandsSeparator": ".",
    "percentage": "false"
    }'
}}

Once the function is evaluated, it displays 2.000,00 in the section where it is used in the message.

Last updated