Liquid request

I have been experimenting with custom totals in theme and I found out just how difficult it is to simply format the calculated number in money format (with commas) and everything

I was wondering if we can get the following liquid tags and filters, that would make thing a little bit easier:

  • money_without_currency filter (for the US format #,###.00 )
  • modulo filter (for all other formats)
  • {% cycle %} seems hit and miss at times

Could we also have the currency Code and Symbol exposed to themes, so we don’t have to hard code the currency symbol for calculated figures.

3 Likes

I wish if I could help, unfortunately I have zero skills in this field.

1 Like

This is what we use to add a cell below the total sum on our invoices, to show the equivalent in local currency:

{{ "Equivalent Total Amount in AED" }} AED {{ table.totals["Total"] | times: 36725 | divided_by: 10000 | round: 2 | format: "N2" }}

The exchange rate is 3.6725 but I find it safer to calculate it with whole numbers and then divide with 10000 to get the comma in the right place since we noticed some discrepancy if we do not do it this way.
The format “N2” is to get the number with the right commas and points etc.

I hope this helps.

3 Likes

Then simply don’t comment on it :wink:

1 Like

I think that’s the second time I ask this the same stupid question and I guess you were the one to give me the same answer last time.

But I used this hack:

{% assign array = new_subtotal | plus: total_disc | append: Curr_Symbol | split: "." %}

{% assign temp = array[0] %}
{% assign x = temp | size | minus: 1 %}
        
 {%- capture new_subtotal2 -%}{%- for i in (0..x) -%}{%- if forloop.index0 > 0 -%}{%- if i == 2 or i == 5 or i == 8 -%},{%- endif -%}{%- endif -%}{{temp | slice: i, 1}}{%- endfor -%}{%- endcapture -%}
{% assign new_subtotal2 = new_subtotal2 | append: "." | append: array[1] %}

But this is much better

I guess I should’ve searched the forum a bit more before posting.

1 Like