Skip to main content

default currency depending on language

More
14 years 1 month ago #62168 by nicolas
It's in the modules folder.

Please Log in or Create an account to join the conversation.

More
13 years 9 months ago - 13 years 9 months ago #83663 by Stéphane Corbé
I did what Nicolas suggested but put it directly in index.php
Code:
// Set the currency at the first visit, regarding of the page language function set_currency($app) { $used_languages = [ [ "tag" => "en-us", "currency" => 2 ], [ "tag" => "ja-JP", "currency" => 3 ], [ "tag" => "en-GB", "currency" => 4 ], [ "tag" => "en-AU", "currency" => 6 ], [ "tag" => "zh-TW", "currency" => 111 ], [ "tag" => "ko-KR", "currency" => 145 ] ]; $lang = JFactory::getLanguage(); if(!$app->getUserState('com_hikashop.currency_id',0)) { foreach($used_languages as $language) { if ($language["tag"] == $lang->get('tag')) { $app->setUserState('com_hikashop.currency_id', $language["currency"]); header('Location: '.$_SERVER['REQUEST_URI']); exit(0); } } } }

and called the function here :
Code:
// Dispatch the application. $app->dispatch(); set_currency($app); // Mark afterDispatch in the profiler. JDEBUG ? $_PROFILER->mark('afterDispatch') : null;

I think this is the good way to do, you help the user the first time and after you let him free to choose which couple language/currency he wants.
Last edit: 13 years 9 months ago by Stéphane Corbé. Reason: Format
The following user(s) said Thank You: nicolas

Please Log in or Create an account to join the conversation.

More
13 years 1 week ago #124416 by Karloz
Hello, please where should i put the code ?

When i put both into index.php / template.php i got blank page (i'm using yootheme template)

Please Log in or Create an account to join the conversation.

More
13 years 1 week ago - 13 years 1 week ago #124445 by Karloz
Oh I forgot, i'm using joomla 3 language translations, not falang.

Please any suggestion ?
Last edit: 13 years 1 week ago by Karloz.

Please Log in or Create an account to join the conversation.

More
13 years 1 week ago #124547 by Jerome
Hi,

It does not ask for Falang.
You have to put it in the Joomla index.php file, at the website root folder.

I don't understand why you put it in your "template.php" file.

If you got a blank page, it means that you wrote something wrong in PHP. Check your PHP log to have more details of the error.

Regards,

Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Please Log in or Create an account to join the conversation.

More
13 years 1 week ago - 13 years 1 week ago #124559 by Karloz
Oh i see, i was putting it in the template file - index.php / template.php

Anyway it still doesn't work when i put the code in the root index.php, no currency changes, nothing in log
I changed the language tags and currency id's.

Is there something else what has to be done ? Like currency module visible or ... ?
Last edit: 13 years 1 week ago by Karloz.

Please Log in or Create an account to join the conversation.

More
13 years 1 week ago #124565 by Jerome
Hi

// Set the currency at the first visit, regarding of the page language

If you are sure you made the right modifications, it should set the currency depending the langue on the first visit.
To test it, clean your cookies. You have to open the website like if you was the first time.

Regards,

Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Please Log in or Create an account to join the conversation.

More
13 years 1 week ago #124569 by Karloz
All the time I thought it will be changing the currency along with language switcher, doesn't it ?
Not just for the first visit, i thought for that is the geolocation plugin.

Please how could i be changing the currency together with joomla language switcher module ?

Please Log in or Create an account to join the conversation.

More
13 years 1 week ago #124678 by Xavier
Hi,

You can create a little system plugin which will be called at each page load to change the currency depending on the language.
The code in a previous post can be used and adapted for your needs.
It require php knowledge.

Please Log in or Create an account to join the conversation.

More
13 years 1 week ago #124724 by Karloz
Well i guess it would be better to integrate the changes into language switcher to be able to alternate the currency via currency switcher then as well.

Its also because we are using Joomla articles to display products, where the currency module doesn't affect displayed price.
And currency switcher is displayed just on the checkout page.

Anyway thank you very much.

Please Log in or Create an account to join the conversation.

More
13 years 1 week ago #124758 by Hátle

integrate the changes into language switcher


I would be interested in this solution too, if possible.

Thank you

Please Log in or Create an account to join the conversation.

More
10 years 3 months ago #242417 by bonzomedia
I came across this requirement for my Swiss website where I needed to change the currency depending on de-DE (German German) or de-CH (German Swiss). If German prices to be shown in Euros, if Swiss prices to be shown in Swiss Francs (CHF).

Fortunately, I found this thread! Anyway, I've created a small plug-in called: CurrencyFollowsLanguage which simply maps a system language tag to a hikashop currency ID. You can set up these maps (up to 10, easily extended), in the plugin backend.

Zip file of the plug-in attached.
The following user(s) said Thank You: dyvel

Please Log in or Create an account to join the conversation.

Time to create page: 0.240 seconds
Powered by Kunena Forum