Hey @BenAdams,
Welcome to the Klaviyo Community!
Although you can perform certain math calculations in templates such as addition, multiplication, and division, subtraction is not supported. You can check our Glossary of variable filters Help Center article to see of our most commonly used ones.
Our templates utilize Django and you can find the full scope here.
I hope this helps!
David
Klaviyo does support Liquid, to calculate the amount a person would save with a coupon, you can use the following Liquid code:
{% assign discount_percent = 10 %}
{% assign sub_total = event.extra.SubTotal %}
{% assign discount_amount = sub_total * discount_percent / 100 %}
{% assign total_with_discount = sub_total - discount_amount %}
You saved {{discount_amount | currency}} with your {{discount_percent}}% discount!
Your new total is {{total_with_discount | currency}}.
This code sets the discount percentage to 10%, retrieves the subtotal from the event.extra object, calculates the discount amount, and subtracts it from the subtotal to get the new total with the discount applied.
You can customize the discount percentage and currency formatting to suit your needs.
That’s great thank you.
I ended up doing this: ${{event.extra.SubTotal|multiply:0.1|round_up:2}}
Hey Tonio,
Where are you seeing the documention around including Liquid? This forum post is really the only place I’ve found. When I try to do something similar Klaviyo throws formatting errors.
Hi @Tonio,
Think you can help our @johnathon here?
I believe this was Tonio’s own working and not from a specific document.
-Taylor