Author Topic: Change VirtueMart currency per language  (Read 683 times)

sandomatyas

  • Jr. Member
  • **
  • Posts: 153
Change VirtueMart currency per language
« 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?

sandomatyas

  • Jr. Member
  • **
  • Posts: 153
Re: Change VirtueMart currency per language
« Reply #1 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

sandomatyas

  • Jr. Member
  • **
  • Posts: 153
Re: Change VirtueMart currency per language
« Reply #2 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