Skip to content

Country

Language

Best way to round converted price on Shopify

Best way to round converted price on Shopify

Shopify has its own way of rounding converted prices:

  1. If the original price is an integer and not in Euro:
    • If the converted price is not in Euro, round up to an integer
    • If the converted price is in Euro, round up to .95
  2. If the original price is in two decimals, round up to two decimals

Note that Shopify adds trailing zeros to converted prices regardless of your settings (e.g., display $11 as $11.00 if the price is converted).

If you wish to round them to integer (or any decimal places) without trailing zeros, there is a quick hack around this without using any apps. Performance-wise, this hack is the fastest with no impact on your online store speed.

Round price

Note: this step is only needed if you want customized rounding that is different from Shopify's own rounding of converted prices.

Go to Online Store > Actions > Edit CodeIn your price.liquid file (if you are unable to find this file, please contact your theme developer), find something like this:

assign compare_at_price = target.compare_at_price
assign price = target.price | default: 1999

Replace it with:

assign compare_at_price = target.compare_at_price | divided_by: 100.0 | round | times: 100
assign price =  target.price | default: 1999 | divided_by: 100.0 | round | times: 100

Round price to any decimal places

The above steps showed rounding to integer. If you want to round to a decimal instead, replace all occurrences of round in the previous code blocks with round: n, where n is the number of decimal places you want to round to (e.g., round: 1 for rounding to 1 decimal place).

Remove trailing zeros

Go to Online Store > Actions > Edit CodeIn your price.liquid file, find and replace assign money_price = price | money with assign money_price = price | money_without_trailing_zeros.

Also replace {{ compare_at_price | money }} with {{ compare_at_price | money_without_trailing_zeros }}.

Make sure to turn off Show currency codes in your theme settings, as for most currencies Shopify's "money_with_currency" filter auto-adds trailing 0s when adding currency codes to foreign currencies. Note that this behavior is a result of Shopify following the standardized format for presenting prices with currency codes, and it is not modifiable.

Enjoy this blog post? Try our free currency conversion app that integrates with your theme.

Older Post
Newer Post

5 comments

  • hello, i cannot find my price.liquid file, is it the case that the file may not exit for some theme?

    jessica
  • Thank you so much for that! I spent hours online looking for a way to do this, but it was time well spent once I found this post. Our products are over 100euro and I was really hating the .95 at the end of the converted prices! This worked perfectly, and my shop looks so much better now.

    Pamela
  • Hi,
    I used your code and find it helpful to both display the simpler rounded price on the site, while charging the customer the true lower price. Thank you!

    However, I hoped to removed the trailing zeroes while displaying the rounded price but I also need to show the currency code. Particularly as my shop is in Canadian dollars and I often sell in US dollars. Is this not truly not possible?

    “Make sure to turn off Show currency codes in your theme settings, as Shopify’s “money_with_currency” filter auto-adds trailing 0s when adding currency codes to foreign currencies."

    LC

Leave a comment

Close (esc)

Popup

Use this popup to embed a mailing list sign up form. Alternatively use it as a simple call to action with a link to a product or a page.

Age verification

By clicking enter you are verifying that you are old enough to consume alcohol.

Search

Shopping Cart