Shopify / liquid

Liquid markup language. Safe, customer facing template language for flexible web apps.
https://shopify.github.io/liquid/
MIT License
11.13k stars 1.39k forks source link

Request: Thousands and decimal separators on cart.currency #1704

Open nikitaourazbaev opened 1 year ago

nikitaourazbaev commented 1 year ago

It would be great to be able to access the current currency’s thousands and decimals separators on the cart.currency object as currently there is no reliable way of getting them (for an example, see Dawn’s price range filter).

On a related note, it would be great to be able to access these on shop.currency as well, but that object seems to be more limited than cart.currency (for example, it does not have the symbol)

cfxd commented 1 year ago

I agree, this would be great. For now, I'm getting the separator this way. It's not ideal and it's definitely gross, but it works for my purposes:

{%- capture money_thousand_separator -%}{{ 100000 | money_without_currency | replace: '1', '' | replace: '0', '' | replace: '0', '' | replace: '0', '' | replace: '0', '' | replace: '0', '' | first }}{%- endcapture -%}

{%- capture money_decimals_separator -%}{{ 100000 | money_without_currency | replace: '1', '' | replace: '0', '' | replace: '0', '' | replace: '0', '' | replace: '0', '' | replace: '0', '' | last }}{%- endcapture -%}