Jump to:

2084 Posts in 1005 Topics by 453 members

E-Commerce Modules

SilverStripe Forums » E-Commerce Modules » Currency Euro

Discuss about the various e-commerce modules available:
Ecommerce, SS Shop, SilverCart and SwipeStripe
Alternatively, have a look the shared mailinglist.

Moderators: martimiz, Nicolaas, Sean, frankmullenger, biapar, Willr, Ingo, Jedateach, swaiba, simon_w

Page: 1
Go to End
Author Topic: 2080 Views
  • biapar
    Avatar
    Forum Moderator
    435 Posts

    Currency Euro Link to this post

    Hi,

    I've made currency Euro config, but there is an'error on currency format.

    Error format: 2,000.00 EUR
    Good format: 2.000,00 EUR <--- how setup this?

  • chrisdarl
    Avatar
    Community Member
    33 Posts

    Re: Currency Euro Link to this post

    Don't think it supports this yet.. you would have to make some adjustments to sapphire/core/model/fieldtypes/Currency.php

    Maybe using a decorator / extension to keep upgrade capability

  • biapar
    Avatar
    Forum Moderator
    435 Posts

    Re: Currency Euro Link to this post

    How? Or is a localization problem?

    in mysite/_config.php, I put:

    i18n::enable();
    i18n::set_default_lang('it_IT'); // for Ita
    i18n::set_locale('it_IT');

  • biapar
    Avatar
    Forum Moderator
    435 Posts

    Re: Currency Euro Link to this post

    Now ok...

    in currency.php , I've changed to

    number_format(abs($this->value), 2,',','.');

    from

    number_format(abs($this->value), 2);

    Bye

  • maksfeltrin
    Avatar
    Community Member
    6 Posts

    Re: Currency Euro Link to this post

    In my opinion It's advisable not to modify core classes but simply to extend them eventually overriding original methods. As an example in MyPage.php:

    MyPage_CurrencyEuro extends Currency
    {
    protected static $currencySymbol = '€';

    function Nice()//or NiceEuro() if You don't want to override
    {
    $val = self::$currencySymbol.'&nbsp;'.number_format(abs($this->value), 2, ',', '.') ;
    if($this->value < 0) return "($val)";
    else return $val;
    }
    }

    or in a separate class-file CurrencyEuro.php

    CurrencyEuro extends Currency
    {
    protected static $currencySymbol = '€';

    function Nice()
    {
    $val = self::$currencySymbol.'&nbsp;'.number_format(abs($this->value), 2, ',', '.') ;
    if($this->value < 0) return "($val)";
    else return $val;
    }
    }

    2080 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.