Skip to main content
Solved

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


Forum|alt.badge.img+3

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

Best answer by David To

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
Did this topic or the replies in the thread help you find an answer to your question?

5 replies

David To
Klaviyo Employee
Forum|alt.badge.img+60
  • Klaviyo Employee
  • 2456 replies
  • Answer
  • May 5, 2021

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


Forum|alt.badge.img+4

This doesn’t seem to work for me. Any thoughts @david.to 

 

Save: ${{ event.Price|multiply:0.90|floatformat:2 }}

 


alex.hong
Forum|alt.badge.img+58
  • Klaviyo Alum
  • 1552 replies
  • October 22, 2021

Hi there @mangrovedigital,

 

I believe for events the proper syntax would be: {% currency_format event.Price|multiply:0.9 %}

 

Let me know if that helped,

Alex


Forum|alt.badge.img+1
  • Contributor II
  • 4 replies
  • June 24, 2023

 {% currency_format event.Price|multiply:0.9 %}

doesn’t work

and

{{ event.Price|multiply:0.90|floatformat:2 }}

doesn’t work


stephen.trumble
Community Manager
Forum|alt.badge.img+60

Hey @Weaverc 

With the first syntax you used {% currency_format event.Price|multiply:0.9 %}, are you using this exactly or are you using double curly brackets around it? It should look like this {{% currency_format event.Price|multiply:0.9 %}}.

Let me know if you’ve already tried this or if it still doesn’t work for you.