2

I'm not really good in any sorts of programing, haven't used smarty before. I want to change the monetary format in our Invoice.

{$amount|crmMoney:$currency}

This code displays $1000.00, but I need $1,000.00 or $1,000 , how can I achieve this?

my civicrm version is 5.1.1, joomla 3.9.4, CRM runs in Window 7

updates:
1. thanks to Joachim I notice decimal is working fine, thousand separators is not, whatever I input in Localization Currency> Thousand Separator, nothing displays.

2. upgraded Civicrm to 5.11.0, problem persist.

3. the problem is not in {$amount|crmMoney:$currency} or MONEY.php, I think something's wrong with my settings.

3
  • Is your server on windows?
    – Demerit
    Commented Mar 26, 2019 at 12:34
  • Yes, it's win 7 Commented Mar 27, 2019 at 4:24
  • Ok I will post an answer.
    – Demerit
    Commented Mar 27, 2019 at 12:13

3 Answers 3

2

The crmMoney function uses php's money_format() function to format the numbers. On Windows, this function does not exist! (https://issues.civicrm.org/jira/browse/CRM-650)

However you can use crmNumberFormat to format it yourself, and add in the currency symbol manually, for example, assuming you want the US dollar symbol:

Instead of {$amount|crmMoney:$currency}, use

${$amount|crmNumberFormat:2}

Note the extra $ at the beginning, which outputs the literal dollar sign. The above will also use the separator and decimal point characters you have set up on the admin screen.

3
  • This works for the invoice, thank you so much for the explanation and answer! Additional question, what is the best environment to run CIVICRM, if it's not windows? Commented Mar 28, 2019 at 3:11
  • 1
    Windows is normally fine, but all the developers seem to have macs for some reason, but that's a whole other topic. The main test environment that the offical tests run on is debian and ubuntu linux.
    – Demerit
    Commented Mar 28, 2019 at 3:21
  • another solution blog.nirvan.pagooah.com/… but I havn't tried, I will comment again if this works Commented Mar 28, 2019 at 11:37
2

If you need to change the settings globally, not just for the single statement, you have the option under Administer -> Localization -> Languages, Currency, Locations. There you can define the "Thousands Separator" as well as the "Decimal Delimiter".

0

enter image description here

Joachim, it's like this by default, the thousand separator doesn't work also in Individual> Contribution.

4
  • 1
    The settings look all just like mine. I just checked this in my Civi test installation (version 7.11.0 with Wordpress 5.1) by trying to use the "=" character as a thousands separator - and it worked for screen displays of currency amounts as well as in the printed invoice. Therefore, I assume something else is interfering here. Perhaps there are some customizations in your code/template or some extension may influence this?
    – Joachim
    Commented Mar 22, 2019 at 9:03
  • Maybe it's because i used CIVI 5.1.1 Joomla 3.9.4 , i don't modify codes too much as I'm not sure how they work, never install any templates too, and thank you for helping btw :) Commented Mar 22, 2019 at 9:08
  • Oh, I made typo - it's of course version 5.11.0.
    – Joachim
    Commented Mar 22, 2019 at 9:10
  • Is there any update on this? Is there a way to get the thousands delimiter to work?
    – menachem
    Commented Jan 23, 2020 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.