News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Change VirtueMart currency per language

Started by sandomatyas, February 21, 2017, 14:31:59 PM

Previous topic - Next topic

sandomatyas

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


sandomatyas

Moving from onAfterInitialise to onAfterRoute fixed the problem because JFactory::getLanguage() shows the previous language using onAfterInitialise method