Hi all!
I’ve brought a value in and x100 (product.price | times: 100.0) and it’s giving me 1.3%. But I’m trying to get it to display as 1.30% (to 2 decimal places). Does any one know what liquid I can use for this please? ![]()
Hi all!
I’ve brought a value in and x100 (product.price | times: 100.0) and it’s giving me 1.3%. But I’m trying to get it to display as 1.30% (to 2 decimal places). Does any one know what liquid I can use for this please? ![]()
Hi @danielstew
I may be wrong here but you could try making the times command to two decimal places?
i.e.
product.price | times: 100.00
That might retain the trailing zero?
If not you could try a round with 2 decimal places too?
product.price | times: 100.00 | round: 2
Just off the top of my head anyway!
Hi @danielstew ,
You cab try below code:
product.price | times: 100.0 | round: 2
If you feel like my answer is helpful, please mark it as a SOLUTION. Let me know if you have any further questions.
Hi @danielstew
You can check number of digit length after decimal and append “0”
Ex:
{% assign price = product.price | times: 100 | round: 2 %}
{% assign price_check = price | split: '.' %}
{% if price_check[1].size == 1 %}
{% assign price = price | append: '0' %}
{% endif %}
Hi, can someone help me with the coding of the 2 decimals?
Hi @Antracite , have you tried my code?