Skip to content

Money

Warning

If you're dealing with money-related tasks, it's a great idea to use this filter. The money filter is here to make sure the display and round off monetary amounts is consistent and accurate across your theme. Failure to exploit the money filter, could result in mistakes or inconsistencies that could cause financial problems. So, make sure to take extra care and follow best practices when dealing with money in your code.

Basic usage

The "money filter" is a filter available in the Liquid templating language, that can be utilized to format any numeric value that represents a monetary amount.

The default implementation of this filter generates a currency symbol based on your store's currency settings, and formats the value accordingly, resulting in a basic currency display.

Example

Data
json
{
  "product": {
    "price": "10.00"
  }
}
liquid
{{ product.price | money }}

Output

$10

Multi currency

When the multi-currency setting is turned on in your YouCan store, the money filter will automatically take this into consideration and output the product price in the customer's selected currency.

For example, let's say your store has two currencies available - USD and EUR - and a customer from Germany visits your store and selects EUR as their currency. When they view a product with a price of $10.00 USD, the money filter will automatically convert the price to EUR using the current exchange rate and display it in the customer's selected currency.

Example

Data
json
{
  "product": {
    "price": "10.00"
  }
}

The present geographical location of the customer is designated as France, thereby determining the corresponding currency as EUR. In this context, it is presumed that the existing conversion rate is 1 USD = 0.85 EUR.

liquid
{{ product.price | money }}

Output

8.50 €