Fixed How to remove decimals in currency format

Affected version


I want to show price without decimals, and the moneyformat has been deprecated in PHP7.4.

Does anybody have a bit of quick advice on what I can add in this field to make $1,234.50 --> $1,234 (no decimals)


Or, where I can alter the code manually in the files...
Last edited:

Chris D

XenForo developer
Staff member
This is actually a bug because we don't actually support money_format formatting. You can only control the position of the {symbol} and the {value} and they are the only two tokens we support (though admittedly there aren't really many other permutations left).

We'd probably be looking to clarify what format "Other" expects.

To answer your question, the currency format defined in the language isn't actually what should control the decimals or precision. In fact the rules of each specific currency are what control that.

Many currencies do display currencies to two decimal places but only a handful of currencies worldwide don't actually have that concept.

For example if you wanted to display a value in "Japanese yen" then it would look like this ¥1000 because that currency has no real concept of fractional units.

So, all that being said, there's currently no support for doing what you want, but we will clarify the meaning of this "Other" field going forward.

Chris D

XenForo developer
Staff member
I mean if it was significant enough for you to want to modify it either with a direct code edit or an add-on then you would extend/edit the XF\Data\Currency class and extend/modify the getCurrencyData method.

'USD' => ['code' => 'USD', 'symbol' => '$',    'precision' => 2, 'phrase' => 'currency.usd', 'fa' => 'fa-dollar-sign'],
Would become:
'USD' => ['code' => 'USD', 'symbol' => '$',    'precision' => 0, 'phrase' => 'currency.usd', 'fa' => 'fa-dollar-sign'],
Though note that a value of 1234.50 would become 1235 in that case due to rounding.

XF Bug Bot

XenForo bug fixer bot
Staff member
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.1.10).

Change log:
Make the appropriate usage of a language's currency_format value more clear.
There may be a delay before changes are rolled out to the XenForo Community.