I am using Views and Drupal Commerce in Drupal 7 to display a list catalogue of products (books).

By default the price column is formatted "12.34 ZAR" which is a format that is only really used in an international currency trade context for South African Rand. How do I override the format so that I can display it as "R12.34" which is the more common format.


You can do it just for your site using hook_commerce_currency_info_alter(), but more appropriately check out the information in the Drupal Commerce FAQ on Currency Formatting to get the proper format in core. The reason it's showing up as 12.34 ZAR is because that's just the bland default format we use for currencies we didn't know how to format. : )

| improve this answer | |
  • Thanks, Ryan. Logged the request in the issue queue My first ever Issue Log, whoa :-) – Martin Duys May 25 '11 at 7:22
  • w00t - I just committed the patch from Haza. It'll be in the next release - welcome to contributor-hood. ^_^ – Ryan Szrama May 26 '11 at 2:47
  • 1
    It's been quite a day. I've installed Git, set up a github account, created a cert, connected to the drupal repository, downloaded the latest version of commerce, downloaded the patch, applied it, and finally updated my site. Where it is working like a charm. Let's just say that the only step of this process that I knew what to do when I started was the 'updated my site' one' :-) – Martin Duys May 27 '11 at 13:51

You can use the Commerce Currency Settings module. This will allow formatting to be configured from the Web UI.

| improve this answer | |

Commerce Currency Settings module changes the Currency format sitewide. I recommend using the:

  1. Price formatter: Raw amount, exclude it from display
  2. Global: Math expression, e.g. [commerce_price]/100 (Drupal commerce often uses the minor unit: pennies etc.)
  3. Global: Custom text, e.g. R[expression]

This will allow you to use Views to display as you wish in the View without additional coding or modules.

This method can also be used for schema.org price itemprop, which requires decimal syntax without symbol, see: https://schema.org/price

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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