When switching from the default dollar sign to euro, the € sign is displayed behind the price instead of in front of it.

So "100.00 €" should be "€ 100.00"

CommentFileSizeAuthor
#26 commerce_euro_sign-7.x-1.x.tar_.gz381 bytesStan Turyn
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pcambra’s picture

It seems that depending on the country/language, € symbol goes before amount or after amount:
http://evertype.com/standards/euro/formats.html

Argus’s picture

Ok, then the display should follow regional settings in admin/config/regional/settings

Currently it doesn't seem to do so (checked after clearing cache).

pcambra’s picture

Hi, not sure if we want to take care of every case depending on language/country, as workaround you can use hook_commerce_currency_info_alter to alter the 'symbol_pacement' property.

pcambra’s picture

Status: Active » Needs work

I was thinking on this, maybe we could add a rule action to change the properties of the currency on "calculating the sell price of a product"
https://skitch.com/pcambra/rck2b/editing-reaction-rule-currency-symbol-d...

rszrama’s picture

Title: Euro sign is displayed behind the price » Add a way for currency formatting to be configured
Component: Price » Contributed modules
Category: bug » feature
Status: Needs work » Active

Hmm, I don't think using that event is a good way to do this, as it's really just a formatting issue and not a price calculation issue. Other than using the hook pcambra recommends, though, I'm not sure we'll get a decent solution to this in core. I could see space for a contributed module providing a UI for currency formatting based on language, though.

fwiw, the current formatting is based on France's use, but even in France it's going to be different from locale to locale (i.e. 100,00 € vs. 100€00).

rszrama’s picture

Version: 7.x-1.0-alpha5 » 7.x-1.x-dev
Priority: Minor » Normal
Status: Active » Postponed

Whoops, noticed the version was still alpha5. I'm marking this postponed as it's really a problem for contrib to solve.

Argus’s picture

Perhaps there is a way using the "Rewrite the output of this field" function in Views work to solve this? Can't get it to work using the currently available tokens:

[entity_id] == Fields: commerce_price
[entity_id-amount] == Raw amount
[entity_id-currency_code] == Raw currency_code
[entity_id-data] == Raw data

rszrama’s picture

That would work for Views field displays, but that operates outside of normal field rendering. I think what will end up needing to happen is just a contrib module that lets you build currency alterations for the various formatting properties of the different currencies. I suppose a token based approach could work as well in conjunction with a custom format_callback.

GiorgosK’s picture

Status: Postponed » Fixed

isn't this issue solved by implementing as per commerce.api.php

function hook_commerce_currency_info_alter(&$currencies, $langcode) {
//example
  $currencies['CHF']['code_placement'] = 'after';
}

in your own module ?

rszrama’s picture

Status: Fixed » Postponed

Yeah, but I think the idea behind this issue is to actually have a module that lets you fiddle with the formatting via the UI.

Argus’s picture

Correct, 1) for the not so coding savvy and 2) because it is easier with less chance of less optimal code.

drupal@guusvandewal.nl’s picture

@GirogosK

Hi, for me it should be symbol_placement. Thanks for putting me on the right track.

In my template.php

function hook_commerce_currency_info_alter(&$currencies, $langcode) {
//example
//dsm($currencies);
 $currencies['EUR']['symbol_placement'] = 'before';
}

Grtz,

Gus

george esper’s picture

This should be a general internationalization/localization issue.

Here in Canada, when displaying prices in English, we format as: $1,234.00.

Whereas, in French, we would format as: 1 234,00$.

Both use CAD as the currency code, but the location of the currency symbol is different. The thousandth and decimal separators are also different.

Price fields should be of type "Currency" or something similar, with formatting done according to regional settings.

Argus’s picture

Agreed. One would expect currency formatting to follow the general internationalization/localization settings in Drupal. In that case a multi-language commerce site would have the currency settings correct for each language.

Currency formatting search on D.O

Xano’s picture

amateescu and I want to tackle this problem in the next version of http://drupal.org/project/currency, so other modules can use proper currency formatting as well.

silkogelman’s picture

Sounds like a great plan.

For those that need to put the € sign before the price today there is this little sandbox module:
http://drupal.org/sandbox/s1l/1512162

(it does the hook_commerce_currency_info_alter mentioned in #9 and #12)

Argus’s picture

Thanks people!

Summit’s picture

Hi, I tried the module from #16, but no go...my prices keep being 12,45 € instead of € 12, 45.
Could it be the problem I have selected "formatted amount" price formatter?

Greetings, Martijn

Summit’s picture

Hi,

Sorry but the only thing that worked was hacking commerce by changing:

function commerce_commerce_currency_info() {
  return array(
...
    'EUR' => array(
      'code' => 'EUR',
      'symbol' => '€',
      'name' => t('Euro'),
      'thousands_separator' => ' ',
      'decimal_separator' => ',',
      'symbol_placement' => 'before',   <= changed 'after' to 'before'
      'code_placement' => '',
      'numeric_code' => '978',
      'minor_unit' => t('Cent'),
      'major_unit' => t('Euro'),
    ),

Greetings, Martijn

fredklopper’s picture

Hi Martijn,

A custom module is working for me:


function MYMODULE_commerce_currency_info_alter(&$currencies, $langcode) {
    $currencies['EUR']['symbol'] = '€ ';
    $currencies['EUR']['symbol_placement'] = 'before';
}

Mention the extra spacer after the € symbol.

Greetings, Fred

Summit’s picture

Hi Fred,

I did as your custom module, but now not the eurosign, but EUR is shown in front?
What could be wrong?

EDIT: I got this: EUR 17,45 €
With this code:
/**
* Implements commerce_currency_info_alter().
*/
function commerce_netherlands_currencydisplay_commerce_currency_info_alter(&$currencies, $langcode) {
$currencies['EUR']['code_placement'] = 'before';
$currencies['EUR']['symbol'] = '€ ';
}

The symbol is not placed in front..and EUR is in front..

greetings, Martijn

Summit’s picture

HI,

I got it! This was the necessary code:


function commerce_netherlands_currencydisplay_commerce_currency_info_alter(&$currencies, $langcode) { 
$currencies['EUR']['symbol_placement'] = 'before';
$currencies['EUR']['symbol'] = '€ '; 
}

Greetings,
Martijn

fredklopper’s picture

Nice!

jhutchtor’s picture

I tried this and no luck. My prices are still display with 10,00 €. I need them to be €10.00 this is the way it people in Ireland expect the price to be and if this doesn't work - as far as I'm concerned this module is completely useless - and I will go back to Ubercart.

Stan Turyn’s picture

You have a very straightforward and working solution provided by Martijn in #22 and yet, of course, it is the module that is useless, it has nothing to do with you ;)

Stan Turyn’s picture

Anyway, for someone looking for this in the future and struggling, a simple module, using Martijn's #22, is attached.

firfin’s picture

thanks and bonus comedy award to Stan :-)

rszrama’s picture

Hmm, my hunch is he didn't clear the cache. Gotta clear it so the hook gets noticed and the currency info array gets reset.

mrfelton’s picture

There was talk about adding this to the Currency module back in April. Looks like this has not happened. I'm actually thinking about adding this feature to Locale Currency (which I'm just about to port to D7). This would allow you to associate a currency and currency format options with individual locals.

jhutchtor’s picture

No your answer is useless and if I want to hear from an ass I will fart

nevets’s picture

That comment is really uncalled for.

pcambra’s picture

@jhutchtor please review drupal code of conduct and think twice before posting a comment like #30 in the future

James A’s picture

Hi mrfelton,

Did you integrate this fix into Local Currency? I had a quick look at the code, with my limited knowledge, but didn't see anything tying it into the hooks referred to above.

If you haven't it would seem to be the most suitable way to do things as then the format simply depends on the individuals PC settings.

mrfelton’s picture

@James A - No, didn't get around to this yet. Just using a custom implementation of the hook for our needs for now. Would be nice to see this added to Locale Currency though.

Connie Chen’s picture

Has this issue (currency location issue) been resolved in Commerce Kickstart 2.0? In Hong Kong, we also write $ 10.00 or HK$ 10.00, and never 10.00 HKD.

rszrama’s picture

@Connie Chen - all you need to do is open an issue with the proper format for your currency and we'll get it fixed; please refer to http://www.drupalcommerce.org/faq/currency-format for more information.

Connie Chen’s picture

@rszrama - thanks for the suggestion. I have opened an issue here: http://drupal.org/node/1799638

feddovdm’s picture

don't forget to re-save the 'currency-settings', this did the trick for me.
admin/commerce/config/currency -> save again.

Jawi’s picture

#26
The module of #26 gives an error message when putting the files in the module folder:

Warning: file_get_contents(sites/all/modules/commerce_euro_sign/commerce_euro_sign.info

Stan Turyn’s picture

Jawi,

Check file permissions on that folder and files and make sure the web server can read the files and read/execute on the directory.

Argus’s picture

currency_commerce may have tackled this problem.

Xano’s picture

The core issue is that Commerce can only change the formatting per currency, which is flexible enough for most webshops (as they only serve a single country), but which is conceptually wrong. Price formatting depends on the locale (country and language) the reader is in. Currency's aim is to provide locale-based currency formatting. Currency for Drupal Commerce was built to format all prices in Commerce using Currency's locale-based formatting.

Argus’s picture

Status: Postponed » Fixed

Then let's close this issue. Check Current for Drupal Commerce for the best currency formatting solution.

rszrama’s picture

Status: Fixed » Postponed

Actually, let's leave this open. That module is basically replacing the currency system by integrating with another contrib module, not just providing a way to configure currency formatting per locale within the existing system.

Xano’s picture

That module is basically replacing the currency system by integrating with another contrib module, not just providing a way to configure currency formatting per locale within the existing system.

That is absolutely correct. Do note that Commerce's currency handling currently serves the 80%, and that 'doing it right' requires quite some insight and extra code to deal with the Unicode CLDR number patterns and different locales. It's not something that is easily replicated (e.g. without adding extra bulk).

pcambra’s picture

martin74’s picture

@Stan Shevchuk and Martijn

Thank you!

jibize’s picture

I am not sure this is the right place/issue to post this (forgive me if it's not), but I created a module that provide a way to display formatted prices according to locale information: https://drupal.org/node/2037573, which hopefully could also fixes issues that people are having here.

I am not sure this is the "right" way to do it, but maybe some more experienced developers than me could have a look at it and provide some feedbacks?

Thank you!

roball’s picture

Status: Postponed » Fixed

As mentioned in #46, the Commerce Currency Settings module does handle that perfectly, doesn't it?

Argus’s picture

Yes, I think is does.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.