Can I remove ".00" (decimals) from the formatted price if it is a whole number?

All currencies that uses cents (or a similar concept where 1 "unit" is equal to a certain number of "subunits") will be rendered with ".00" or ",00" by default . If you mostly sell products with whole numbers, dropping the decimals can can clean things up and increase conversions.

DO NOT edit the currency formatting configuration to set the subunits to 0, as this causes payment gateways to charge the customer a very small amount. 

What you can do, is apply a very simple transform where you render a price. For example in the cart template or your product template.

For example, in a twig template use the replace filter like so:

{{ item.price_formatted|replace({ '.00' : '' }) }}<br>

Note the structure within the replace filter is an object where the key ('.00') has value (an empty string) indicating what it should be replaced with.

In MODX chunks/templates, you can use the replace output filter like so:


In this syntax, the key (.00) is separated from the value (an empty string) by two equal signs.

If your currency uses a comma for the decimal separator instead of a dot, change the examples accordingly.

Still need help? Send us an email Send us an email