VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Coding Central => Topic started by: sandomatyas on February 21, 2017, 14:31:59 PM

Title: Change VirtueMart currency per language
Post by: sandomatyas on February 21, 2017, 14:31:59 PM
I have a customer who has a shop with two languages and two currencies. When the visitor changes the language the currency should change too.
I created a system plugin to do something else and append a code part to onAfterInitialise method which checks if we just changed the language and if we did it tries to change the currency.
I tried some ways to do that:
$app->setUserState( "virtuemart_currency_id", 47 );
JFactory::getApplication()->input->set('virtuemart_currency_id', 47);
VmConfig::loadConfig()->set('user_selected_virtuemart_currency_id', 47);
When I change the language the currency doesn't change but when click somewhere else after that the I get the right currency. But of course I need it to the first click not the second one.
The weird part: It worked with Joomla 2.5 and VM 2.0 but not with the latest one.

Could you help me with this?
Title: Re: Change VirtueMart currency per language
Post by: sandomatyas on February 21, 2017, 16:54:27 PM
I've also tried this plugin: http://www.easyjoomla.org/virtuemart-extensions/language-currency-plugin
But it works the same way and had the same problem
Title: Re: Change VirtueMart currency per language
Post by: sandomatyas on February 21, 2017, 17:12:57 PM
Moving from onAfterInitialise to onAfterRoute fixed the problem because JFactory::getLanguage() shows the previous language using onAfterInitialise method