How to Conditionally Format Currency Display with Commas and Decimals in Shopify

How to Conditionally Format Currency Display with Commas and Decimals in Shopify

Pepijn
Visitor
2 0 0

Hello Shopify Community,

I'm seeking assistance with a specific formatting issue related to currency display on my Shopify store. I would like to customize the way prices are displayed so that they adapt based on the presence of decimals.

Specifically, my goal is to:

  • Display prices without a comma or decimal point when there are no decimals. For example, a price of 1500 euros should be displayed as "1500 euro", without any decimals or comma.
  • Display prices with a comma and decimal points when there are decimals. For instance, a price of 1500.50 should be shown as "1500,50 euro", including the comma and the decimal values.


I'm not sure how to implement this conditional formatting in Shopify's Liquid templates. Could anyone provide guidance or code snippets that would help achieve this dynamic pricing display?

Any help or suggestions from the community would be greatly appreciated!


Thank you!

Replies 0 (0)