spree-contrib / spree_multi_currency

Provides UI to allow configuring multiple currencies in Spree.
http://guides.spreecommerce.org
BSD 3-Clause "New" or "Revised" License
41 stars 118 forks source link

undefined method `supported_currencies' for #<Spree::AppConfiguration:0x00007fc93c9152f0>) #99

Open tasdendu opened 4 years ago

tasdendu commented 4 years ago
Screen Shot 2020-04-27 at 6 02 58 PM

How do we define supported_currencies, I have tried all possible options like

Spree::Config.supported_currencies = ['USD', 'EUD']
Spree::Config[:supported_currencies] = ['USD', 'EUD']
Spree::Config['supported_currencies'] = ['USD', 'EUD']

None of the above configuration work for me. Can some one help me please.

Tashows commented 4 years ago

I am trying to figure this out too. This looks like a very basic step to be missing from the setup.

Edit: There is a field in the admin section. You basically add them in a field coma-separated. "USD, EUR" and they work.

MatthewKennedy commented 4 years ago

Hi @tashi-179

I use this copy for Spree 4 https://github.com/spree-four/spree_multi_currency

Preferences are set in this file: https://github.com/spree-four/spree_multi_currency/blob/master/lib/spree_multi_currency/engine.rb

iamsid-das commented 4 years ago

@Tashows Can you elaborate your solution a little more. Whereabout in the admin section?

MatthewKennedy commented 4 years ago

Hi @Voyotel

I don't think you will find a fix for this from something in the admin, its happening because the preferences have not been initiated properly when the app loads.

What version of Spree are you using and what version of rails are you using?

iamsid-das commented 4 years ago

@MatthewKennedy I'm in Spree 4.1 and rails 6.0.3

MatthewKennedy commented 4 years ago

@Voyotel If you replace the spree-contrib version with this:

gem 'spree_multi_currency', github: 'spree-four/spree_multi_currency'

That should work fine.

The multi currency functionality is being built into Spree 4.2 so at some point that extension will be a legacy extension.

iamsid-das commented 4 years ago

@MatthewKennedy Thanks! That worked :)

mrublya commented 4 years ago

Hi all, adding this to the file application.rb helped me to resolve this problem

  config.after_initialize do
    Spree::Config.allow_currency_change  = true
    Spree::Config.show_currency_selector = true
    Spree::Config.supported_currencies   = 'GBP,USD,EUR'
  end
tasdendu commented 4 years ago

@Voyotel If you replace the spree-contrib version with this:

gem 'spree_multi_currency', github: 'spree-four/spree_multi_currency'

That should work fine.

The multi currency functionality is being built into Spree 4.2 so at some point that extension will be a legacy extension.

This is not the solution. We should figure it out how to fix the current problem.

tasdendu commented 4 years ago

Hi all, adding this to the file application.rb helped me to resolve this problem

  config.after_initialize do
    Spree::Config.allow_currency_change  = true
    Spree::Config.show_currency_selector = true
    Spree::Config.supported_currencies   = 'GBP,USD,EUR'
  end

This looks like promising solution. Let me check and see if it is working.

jembuiltit commented 3 years ago
Hi all, adding this to the file application.rb helped me to resolve this problem

  config.after_initialize do
    Spree::Config.allow_currency_change  = true
    Spree::Config.show_currency_selector = true
    Spree::Config.supported_currencies   = 'GBP,USD,EUR'
  end
This looks like promising solution. Let me check and see if it is working.

this did not work for me .... @tashi-179 and the repo seems to have moved @MatthewKennedy so I can't try your idea.

when I add the above I get app/models/spree/preferences/configuration.rb:64:inmethod_missing': undefined method allow_currency_change=' for #<Spree::AppConfiguration:0x00007fb40d0e5f10> (NoMethodError)

so I remove the first line and so on...but no good

# 
gem 'rails', '~> 6.0.3', '>= 6.0.3.4'
gem 'spree', '~> 4.1'