How to divide and multiple in HTML template

I’m want to customize my sales invoice. I can minus 2 variables eg. below

{% for tax_component in tax_components %}
{% assign ttotal = tax_component.amount %}
{% endfor %}

{% assign sstotal = subtotal | minus:ttotal %}

I can also add eg.

{% assign sstotal = subtotal | plus:ttotal %}

How do i divide and multiply. I tried using "divide, div, division, / " but it does not work.

Please advise.

times

{{ 5 | times:4 }} #=> 20

divided_by

{{ 10 | divided_by:3 }} #=> 3
1 Like

Thanks Kal. Is there a rounding (2 decimal places) method for divided_by. It’s currently giving me eg.
20.1394656778. I want it to be rounded to 20.14.

Appreciate the help!

For rounding, you can use round filter.

{{ 4.5612 | round: 2 }}

will output:

4.56
1 Like

Thanks lubos,

I’ve copied your example in the line of code below and it’s still displaying 4.5612 on the sales invoice. I’m not sure what could be wrong.

It looks like round filter wasn’t supported after all. I’ve just added it to the latest version (15.4.51)

1 Like

@lubos, while we’re on the subject of Liquid support, some time ago in the ‘Introducing HTML/CSS templates’ thread, you referred me to date formatting in Liquid, but it didn’t seem to work, and I’m wondering if this too is something that isn’t yet supported in Manager? Here’s what I wrote in that thread:

Thanks, it works great :smile: