No replies
aurio99
aurio99's picture
Offline
newbie
Last seen: 2 years 40 weeks ago
Timezone: GMT+11
Joined: 2016-10-03
Posts: 1
Points: 2

Hi, I wish to assign a math value so I can then take the ceiling.

My current code is:
{% if variant.compare_at_price > variant.price %}
SAVE {{ variant.compare_at_price | minus:variant.price | times:100 | divided_by:variant.compare_at_price }}%

{% endif %}

Output is SAVE 20% (for example, but if it's 19.99 it'll be 19% rather than 20%)

But I want to call x= {{ variant.compare_at_price | minus:variant.price | times:100 | divided_by:variant.compare_at_price }}%

then take {{ x | ceil }}

How do I assign x?

Thanks in advance.