Some tags return numeric values, but sometimes you need to reformat these values. For example to {customer_total}, {order_total}, {customer_orders_count}, you may want to add a currency symbol, round, add thousands separator or replace the number with its ordinal representation.
For that we have modifiers. In order to use a modifier, simply add it inside the tag, separated by pipe (|) from the tag's name. Modifiers can be chained, to create combinations. See examples below.
The following modifiers are supported:
round - simple numeric round.
How to use: {tag_name|round:precision}
precision - the precision to round to. Default value is 0
Example:
Your total purchases amount in the store is {customer_total|round}
Output: Your total purchases amount in the store is 1148
Your total purchases amount in the store is {customer_total|round:1}
*1 is the precision
Output: Your total purchases amount in the store is 1148.2
roundandformat - same as round, but with thousands separator as well
How to use: {tag_name|roundandformat:precision}
precision - the precision to round to. Default value is 0
Example:
Your total purchases amount in the store is {customer_total|roundandformat}
Output: Your total purchases amount in the store is 1,148
Your total purchases amount in the store is {customer_total|roundandformat:1}
*1 is the precision
Output: Your total purchases amount in the store is 1,148.2
ordinal - add the ordinal suffix to the number
How to use: {tag_name|ordinal:lang}
lang - the language for the ordinal text. Currently 'eng' (English) and 'swe' (Swedish) are supported. Fill free to contact us if you need support for other languages. Default value is 'eng'
Example:
This is your {customer_orders_count|ordinal} order in our store.
Output: This is your 2nd order in our store.
currency - add currency symbol to the number.
How to use: {tag_name|currency}
Exampe:
Your last order was in the amount of {order_total|currency}
Output: Your last order was in the amount of $135
How to combine several modifiers together?
Wrap any tag in a curly brackets creates a virtual tag which can be modified by a new modifier. For example:
{{customer_total_no_shipping|roundandformat}|currency}
Output: $1,148
General note: make sure that there are no spaces before and after the pipe separator, for example:
{order_total | currency} - Not good
{order_total|currency} - Good
Comments
0 comments