Shopify has its own way of rounding converted prices:
- 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
- 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 Code. In 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 Code. In 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.
5 comments
Great post, thanks a lot.
When I go to the checkout, the original unrounded price will show. Is there a possible way to change that?
Best, Daniel
Thank you so much for this!