How to change spree currency?
I have trouble with spree, a开发者_StackOverflownd dont know how to deal with it. I can't change the main currency.
How can I do it?
It's easier in Spree 2.0.0 and obviously it will work in previous versions of spree too.
Go to your config/initializers/spree.rb
and in Spree.config block write the following code.
Spree.config do |config|
config.currency = 'EUR'
end
If you just want to show some other currency sign in Spree than $ you have to change that in Rails locale file in your Spree project. Example for Estonian locale and Euro is on the below.
config/locales/et_rails.yml:
et:
number:
# Used in number_to_currency()
currency:
format:
# Where is the currency sign? %u is the currency unit, %n the number (default: $5.00)
format: "%n %u"
unit: "€"
# These three are to override number.format and are optional
separator: "."
delimiter: " "
precision: 2
Maybe other alternative is to use Multi Currency plugin: http://spreecommerce.com/extensions/94-spree-multi-currency
For spree 1.3.x, we have to set the :currency preference.
Eg. config/initializers/spree.rb
Spree.config do |config|
...
config.currency = 'EUR'
end
I tried in spree 0.11 with rails 2. To change currency or change other localization following things needs to be done.
- Copy en_spree.yml file from spree/config/locales/ folder to /config/locales/ folder. (this file can be with some different name also depends on default locale).
- Save this file with en.yml also in /config/locales/ folder. Its a replication.
- Do modification for any string or currency. For currency follow above answer of Priidik Vaikla.
modify spree.rb in your /config/initializers/ folder by adding this line:
Spree::Config.set(:default_locale => 'en')
Note: you can change default en with other language but .yml file names should change accordingly.
Restart your server and check the output.
精彩评论