falatrax Posted January 17, 2012 Share Posted January 17, 2012 Hi! I just added a second language (english) to my site. When a customer switch the site to english I want to switch the currency to Euro. How can I do that, how can I link a currency to language ? thanks. flx. presta v. 1.4.6.2 Link to comment Share on other sites More sharing options...
Rolige Posted January 18, 2012 Share Posted January 18, 2012 In "classes/Tools.php" locate this code below: public static function switchLanguage() { global $cookie; if ($id_lang = (int)(self::getValue('id_lang')) AND Validate::isUnsignedId($id_lang)) $cookie->id_lang = $id_lang; } Remplase for this below: public static function switchLanguage() { global $cookie; if ($id_lang = (int)(self::getValue('id_lang')) AND Validate::isUnsignedId($id_lang)) { $cookie->id_lang = $id_lang; switch($id_lang) { case 1: //if lang_id that's changed to is = 1 than... $cookie->id_currency = 1; //change the currency too, the currency that has the id 2 self::setCurrency(); break; } } } The problem with this is that after not giving you the ability to change the currency as long as you choose English If you need to create more conditions, only adds more: case 1: //if lang_id that's changed to is = 1 than... $cookie->id_currency = 1; //change the currency too, the currency that has the id 2 self::setCurrency(); break; Only change "case 1:" to id language you need and "$cookie->id_currency = 1;" to currency for that case. Remenber activate Forze compile. Link to comment Share on other sites More sharing options...
tomerg3 Posted January 18, 2012 Share Posted January 18, 2012 You can check out the following module that does that and more http://www.prestashop.com/forums/index.php?/topic/105240-module-location-detection-detect-the-location-of-a-visitor-using-their-ip-address-and-automatically-redirect-them-to-the-matching-language/ Link to comment Share on other sites More sharing options...
falatrax Posted January 18, 2012 Author Share Posted January 18, 2012 O.K. Thanks guys ! Link to comment Share on other sites More sharing options...
antonpetr Posted December 7, 2012 Share Posted December 7, 2012 there's a real solution here http://www.prestashop.com/forums/index.php?/topic/52019-change-currency-automatically-when-switching-from-one-language-to-another/page__view__findpost__p__910944 Link to comment Share on other sites More sharing options...
mexis Posted February 11, 2017 Share Posted February 11, 2017 For 1.6.1.x open /classes/Tools.php find this code: $currency = Currency::getCurrencyInstance(Configuration::get('PS_CURRENCY_DEFAULT')); replace for this $currency = Currency::getCurrencyInstance(1); number 1 = currency id Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now