Solved

Message template, any way to use simple arithmetic on values?

  • 5 May 2021
  • 1 reply
  • 104 views

Badge

Is there any way to use simple maths in the message templates? e.g. {{ item.ItemPriceInEuroTotal * 0.95|floatformat:2 }} throws a formatting error because of the “* 0.95”. Is there any way I can do this in the template? thanks

icon

Best answer by david.to 5 May 2021, 19:15

Hello @shane.mitchell,

Great question!
Performing math in email templates is supported through the use of variable filters. If you wish to multiple a variable, you can use the |multiply tag. 

From your example of multiplying the {{ item.ItemPriceInEuroTotal }} variable by 0.95, and applying a float format filter of 2, you can use the following syntax: {{ item.ItemPriceInEuroTotal|multiply:0.95|floatformat:2 }}

You can learn more about using variables, variable tags, and a list of commonly used tags from the following articles:

Hope this helps!

-David

View original

1 reply

Userlevel 6
Badge +4

Hello @shane.mitchell,

Great question!
Performing math in email templates is supported through the use of variable filters. If you wish to multiple a variable, you can use the |multiply tag. 

From your example of multiplying the {{ item.ItemPriceInEuroTotal }} variable by 0.95, and applying a float format filter of 2, you can use the following syntax: {{ item.ItemPriceInEuroTotal|multiply:0.95|floatformat:2 }}

You can learn more about using variables, variable tags, and a list of commonly used tags from the following articles:

Hope this helps!

-David

Reply