Jump to content

change currency automatically when switching from one language to another


Recommended Posts

in classes/Tools.php
for a quick fix just replace switchLanguage function with this one, making sure you edit the id's bellow with your own needs:

    static public function switchLanguage()
   {
       global $cookie;

       if ($id_lang = intval(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 = 2;  //change the currency too, the currency that has the id 2
                   self::setCurrency();
                   break;
               case 2: //and so on ....
                   $cookie->id_currency = 1;
                   self::setCurrency();
                   break;
               case 3: 
                   $cookie->id_currency = 1;
                   self::setCurrency();
                   break;
               case 4:
                   $cookie->id_currency = 4;
                   self::setCurrency();
                   break;
           }
       }
   }

Link to comment
Share on other sites

  • 2 months later...
  • 2 months later...

Can somebody please help me? i tried this but always get following error: Parse error: syntax error, unexpected T_PUBLIC, expecting T_VARIABLE in /kunden/286138_22145/webseiten/classes/Tools.php on line 208



this i did put into the tools.php


   static public function switchLanguage()
       {
       global $cookie;

       if ($id_lang = intval(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 = 3;  //change the currency too, the currency that has the id 2
                   self::setCurrency();
                   break;
               case 2: //and so on ....
                   $cookie->id_currency = 1;
                   self::setCurrency();
                   break;
               case 3: 
                   $cookie->id_currency = 1;
                   self::setCurrency();
                   break;
               case 4:
                   $cookie->id_currency = 1;
                   self::setCurrency();
                   break;
       case 5:
                   $cookie->id_currency = 1;
                   self::setCurrency();
                   break;
           }
       }
   } 

Link to comment
Share on other sites

  • 3 months later...
  • 2 months later...
  • 2 months later...
  • 1 month later...
  • 1 month later...
  • 2 months later...

... but if you want to change currency in the Bankwire payment, the currency can't be changed.

 

I would like to know how to change it also, I want to process all my payments in Default currency, and I don't seem to be able to find the information in the forum.

Link to comment
Share on other sites

  • 2 weeks later...

This is what I did in my moneris credit card payment processing that I am writting:

 

// check currency of payment and force to Canadian dollar***********************
if ($currency_order->id != 4)
{
 $cookie->id_currency = 4;
 $cart->id_currency = 4;
 $cart->update();
}

 

All credit card payments have to be processed in Canadian $ in my case, so I am forcing the currency to 4 (Cdn$).

 

I hope this helps.

Link to comment
Share on other sites

We have a module "Location Detection" (http://www.prestashop.com/forums/index.php?/topic/35119-module-location-detection-detect-the-location-of-a-visitor-using-their-ip-address-and-automatically-redirect-them-to-the-matching-language/) that opens up the shop in the customer's language (based on their IP or browser language), and also has the ability to link a flag to a currency.

You can still change the currency, as it only "links" them when you click on the language flag

Link to comment
Share on other sites

  • 8 months later...

Why it's not possible to change currency after?

I would like to let the possibily to change currency after, not to "force" to this currency...

 

Thank you for you help!

 

yes, I have seen this problem as well.

 

description:

before chris2407 's hack

- changing language - currency does not change

- changing currency - language does not change

 

after chris2407 's hack

- changing language - currency changes

- changing currency - PROBLEM - currency does not change (PS 1.4)

 

I dont know PS always calls switchLanguage() and setCookieLanguage() on every page load.

Clicking on currency calls changecurrency.php via AJAX call which then changes cookie value of id_currency

 

I have resolved the problem using additional cookie value in changecurrency.php, so the moment of changing currency can be detected :>

 

my complete solution (based on chris2407 mod)

 

 

changecurrency.php (added lines in bold)

 

$cookie->id_currency = (int)($currency->id);

$cookie->id_currency_changed = 1;

die('1');

 

 

Tools.php (complete functions, I have added second function)

 

  static public function switchLanguage()
{
	global $cookie;

	if ($id_lang = intval(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...
				self::switchCurrencyLinked(3);
				break;
			case 6: //and so on ....
				self::switchCurrencyLinked(4);
				break;
		   }
	}
}

static public function switchCurrencyLinked($cookieLanguage)
{
	global $cookie;

	if (! (int)$cookie->id_currency_changed)
	{
		$cookie->id_currency = $cookieLanguage;
		self::setCurrency();
	}
	else
	{
		$cookie->id_currency_changed = 0;
	}
}

 

 

 

good luck! :)

 

 

PS

debug problems in prestashop by enabling errors in config.inc.php :

@ini_set('display_errors', 'on');

and then in any php file print variables using trigger_error

trigger_error("variable dump".print_r($var));

Edited by devein (see edit history)
  • Like 3
Link to comment
Share on other sites

In general I hope the way prestashop handles currencies should be enhanced. I did not check the behaviour in 1.5. so far but it would be much better to not store currencies in a cookie(ot at least not only). There should be a least the possibility to attach a default currency per country/language/store view. As search engine do not accept cookies there are problems with the current behaviour. For example if I enable geolocation module the google bot will be determined as USA based therefore the prices are served in $US. As google uses currencies as a signal to taget the audience of the site I might loose some seo points for my others "views"

Best behaviour in my opinion would be:

bot crawls

www.mysite.com/us/... -> $us would be triggered

www.mysite.com/au/... -> $AUS would be triggered

www.mysite.com/de/... -> € would be triggered

www.mysite.com/uk/... -> pound would be triggered

 

This structure would also protect protect duplicate content issiues as google bot can clearly see the target country. It should not be

a problem to serve the same content under diffenrent countries as it is clear different countries are targeted.

Sorry, maybe a little bit of topic but I think every one running an international site should be aware of such problems.

I already posted that on the but tracker

http://forge.prestashop.com/browse/PSCFI-6155 and related to the issue http://forge.prestashop.com/browse/PSCFI-2951

 

Regards, trip

  • Like 1
Link to comment
Share on other sites

  • 1 month later...
  • 4 weeks later...

Thank you that works perfect on 1.4.8.2

 

yes, I have seen this problem as well.

 

description:

before chris2407 's hack

- changing language - currency does not change

- changing currency - language does not change

 

after chris2407 's hack

- changing language - currency changes

- changing currency - PROBLEM - currency does not change (PS 1.4.8.2)

 

I dont know PS always calls switchLanguage() and setCookieLanguage() on every page load.

Clicking on currency calls changecurrency.php via AJAX call which then changes cookie value of id_currency

 

I have resolved the problem using additional cookie value in changecurrency.php, so the moment of changing currency can be detected :>

 

my complete solution (based on chris2407 mod)

 

 

changecurrency.php (added lines in bold)

 

$cookie->id_currency = (int)($currency->id);

$cookie->id_currency_changed = 1;

die('1');

 

 

Tools.php (complete functions, I have added second function)

 

  static public function switchLanguage()
{
	global $cookie;

	if ($id_lang = intval(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...
				self::switchCurrencyLinked(3);
				break;
			case 6: //and so on ....
				self::switchCurrencyLinked(4);
				break;
		   }
	}
}

static public function switchCurrencyLinked($cookieLanguage)
{
	global $cookie;

	if (! (int)$cookie->id_currency_changed)
	{
		$cookie->id_currency = $cookieLanguage;
		self::setCurrency();
	}
	else
	{
		$cookie->id_currency_changed = 0;
	}
}

 

 

 

good luck! :)

 

 

PS

debug problems in prestashop by enabling errors in config.inc.php :

@ini_set('display_errors', 'on');

and then in any php file print variables using trigger_error

trigger_error("variable dump".print_r($var));

Link to comment
Share on other sites

  • 1 month later...

This is working perfectly on 1.4.8.2! Superb job! Thank you devein!

 

 

yes, I have seen this problem as well.

 

description:

before chris2407 's hack

- changing language - currency does not change

- changing currency - language does not change

 

after chris2407 's hack

- changing language - currency changes

- changing currency - PROBLEM - currency does not change (PS 1.4.8.2)

 

I dont know PS always calls switchLanguage() and setCookieLanguage() on every page load.

Clicking on currency calls changecurrency.php via AJAX call which then changes cookie value of id_currency

 

I have resolved the problem using additional cookie value in changecurrency.php, so the moment of changing currency can be detected :>

 

my complete solution (based on chris2407 mod)

 

 

changecurrency.php (added lines in bold)

 

$cookie->id_currency = (int)($currency->id);

$cookie->id_currency_changed = 1;

die('1');

 

 

Tools.php (complete functions, I have added second function)

 

  static public function switchLanguage()
{
	global $cookie;

	if ($id_lang = intval(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...
				self::switchCurrencyLinked(3);
				break;
			case 6: //and so on ....
				self::switchCurrencyLinked(4);
				break;
		   }
	}
}

static public function switchCurrencyLinked($cookieLanguage)
{
	global $cookie;

	if (! (int)$cookie->id_currency_changed)
	{
		$cookie->id_currency = $cookieLanguage;
		self::setCurrency();
	}
	else
	{
		$cookie->id_currency_changed = 0;
	}
}

 

 

 

good luck! :)

 

 

PS

debug problems in prestashop by enabling errors in config.inc.php :

@ini_set('display_errors', 'on');

and then in any php file print variables using trigger_error

trigger_error("variable dump".print_r($var));

Link to comment
Share on other sites

  • 3 months later...
  • 2 months later...
  • 2 months later...

Maybe I solve this for prestashop 1.5.2 -> thx to devein´s and chris2407´s guides

 

bold I added

 

in 1.5.2. -> controllers/front/ChangeCurrencyController.php

 

class ChangeCurrencyControllerCore extends FrontController
{
/**
 * Assign template vars related to page content
 * @see FrontController::initContent()
 */
public function initContent()
{
 $currency = new Currency((int)Tools::getValue('id_currency'));
 if (Validate::isLoadedObject($currency) && !$currency->deleted)
 {
  $this->context->cookie->id_currency = (int)$currency->id;
[b]   $this->context->cookie->id_currency_changed = 1;[/b]
  die('1');
 }
 die('0');
}
}

 

in classes/Tools.php

 

/**
 * Set cookie id_lang
 */
public static function switchLanguage(Context $context = null)
{
.
...some original code here....
.
  if (Configuration::get('PS_REWRITING_SETTINGS') || !Language::isMultiLanguageActivated())
   unset($params['id_lang']);

  [b]switch($id_lang)
  {
    case 7: //if lang_id that's changed to is = 1 than...
	  self::switchCurrencyLinked(1);
	  break;
    case 9: //and so on ....
	  self::switchCurrencyLinked(3);
	  break;
    case 10: //and so on ....
	  self::switchCurrencyLinked(3);
	  break; 
  } [/b]
 }
}

[b] /**
 * New functions by devein
 *
 */

 static public function switchCurrencyLinked($cookieLanguage)
 {
   global $cookie;

   if (! (int)$cookie->id_currency_changed)
   {
	    $cookie->id_currency = $cookieLanguage;
	    self::setCurrency();
   }
   else
   {
	    $cookie->id_currency_changed = 0;
   }
 }[/b]

 

It works for me well :)

  • Like 1
Link to comment
Share on other sites

  • 3 months later...
  • 1 month later...

Works partly for me on 1.5.6.0.

Make sure to modify the contents of the Switch to your currency and language id's. So check your id's in the admin / Localisation.

 

To make it work FULLY I actually also moved the switch outside it's container "IF" to make sure it also was default set.

 

Now it works perfectly. The solution is however very hardcoded/ugly, It should be possible to make a solution that only needs a boolean setting to make it happen.

Edited by [email protected] (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 4 months later...
replace with built-in switchLanguage function
tested in prestashop 1.5.6
/**
* Set cookie id_lang
*/
public static function switchLanguage(Context $context = null)
{
if (!$context)
$context = Context::getContext();
 
// Install call the dispatcher and so the switchLanguage
// Stop this method by checking the cookie
if (!isset($context->cookie))
return;
 
if (($iso = Tools::getValue('isolang')) && Validate::isLanguageIsoCode($iso) && ($id_lang = (int)Language::getIdByIso($iso)))
$_GET['id_lang'] = $id_lang;
 
// update language only if new id is different from old id
// or if default language changed
$cookie_id_lang = $context->cookie->id_lang;
$configuration_id_lang = Configuration::get('PS_LANG_DEFAULT');
if ((($id_lang = (int)Tools::getValue('id_lang')) && Validate::isUnsignedId($id_lang) && $cookie_id_lang != (int)$id_lang)
|| (($id_lang == $configuration_id_lang) && Validate::isUnsignedId($id_lang) && $id_lang != $cookie_id_lang))
{
$context->cookie->id_lang = $id_lang;
$language = new Language($id_lang);
if (Validate::isLoadedObject($language) && $language->active)
$context->language = $language;
 
$params = $_GET;
if (Configuration::get('PS_REWRITING_SETTINGS') || !Language::isMultiLanguageActivated())
unset($params['id_lang']);
 
switch($id_lang) {
case 1:
$cookie->id_currency = 1;
self::switchCurrencyLinked(1);
break;
case 4:
$cookie->id_currency = 2;
self::switchCurrencyLinked(2);
break;
case 5:
$cookie->id_currency = 4;
self::switchCurrencyLinked(4);
break;
}
}
}
 
public static function switchCurrencyLinked($cookieLanguage)
{
global $cookie;
 
if (!(int)$cookie->id_currency_changed)
{
$cookie->id_currency = $cookieLanguage;
self::setCurrency();
}
else
{
$cookie->id_currency_changed = 0;
}

 

 

 

Edited by PEteam (see edit history)
Link to comment
Share on other sites

  • 3 months later...

with this module

 

http://www.prestashop.com/forums/topic/349727-module-advanced-visitor-language-currency-localization-ietf/

 

once installed bo-->localization-->countries-->edit country (set default currency that country)

 

then it matches visitor language based on quality factor in http_accept_languages, sets cookies language, then set's currency based on ietf country.

 

This post not so much that I want your to buy module, I'm just like to show my work in this area.  :)

 

, this takes guess work out of localization, as guessing = poor visitor experience.

Link to comment
Share on other sites

Hi,

 

i checked your module before when i was researching this subject.

 

It seems to be perfect for what i want! But i promised myself i wouldn't spend more money on the site until i get some sales :unsure:

 

and on a personal note, changing currency based on language is not advise, my two cents.

 

Why is that? Can you explain please, i sont see any downside...

Link to comment
Share on other sites

Hi,

 

i checked your module before when i was researching this subject.

 

It seems to be perfect for what i want! But i promised myself i wouldn't spend more money on the site until i get some sales :unsure:

 

 

Why is that? Can you explain please, i sont see any downside...

 

this is my first 'advanced module' so I am having difficult time explaining (more doc coming soon).  Basically you install module, edit each country and assign default currency (using native prestashop) and sleep easier at night.  remember, visitor and search engine localization is not about guessing. :)

Link to comment
Share on other sites

  • 1 month later...

Hi guys

 

i'm trying to have this workaround working on my 1.6 prestashop but so far coud not get it working.

Anyone tested it on 1.6 ?

 

Thanks

 

You can make it work on 1.6 too. I´d started from post #15 in this topic, where Devein modified Chris2407 's first hack hack:

http://www.prestashop.com/forums/topic/52019-change-currency-automatically-when-switching-from-one-language-to-another/?do=findComment&comment=910944

 

Full change to this modification maded for PS 1.5 is now applied to PS 1.6 ( I have 1.6.0.9 but it should work from 1.6.0.0 too )

 

1. Make copy of ChangeCurrencyController.php to /override/controllers/front/ChangeCurrencyController.php

find:

$this->context->cookie->id_currency = (int)$currency->id;

change to:

$this->context->cookie->id_currency = (int)$currency->id;
$this->context->cookie->id_currency_changed = 1;

2. Make copy of Tools.php to /override/classes/Tools.php

in public static function switchLanguage find:

$language = new Language($id_lang);

change to:

$language = new Language($id_lang);
            
            // added for hard currency linked switch
            switch($id_lang) {
                case 1: //if lang_id that's changed to currency id = 1 than...
                    Tools::switchCurrencyLinked(1);
                    break;
                case 2:
                    Tools::switchCurrencyLinked(2);
                    break;
                case 3: //and so on ....
                    Tools::switchCurrencyLinked(3);
                    break;
               }
            //
           

Immediately after end of function public static function switchLanguage insert new function:

/**
     * Change cookie currency with Language when hard currency linked switch - janoo
     *
     */
     static public function switchCurrencyLinked($cookieLanguage)
    {
        global $cookie;

        if (! (int)$cookie->id_currency_changed)
        {
            $cookie->id_currency = $cookieLanguage;
            Tools::setCurrency($cookie);
        }
        else
        {
            $cookie->id_currency_changed = 0;
        }
    }

Credits goes to Devein and Chris2407. I´d just modified idea to PS 1.6

 

But don´t forget: make second/third/... currency active! And parse id of language with id of currency precisely.

 

I´d tested it correctly and it worked also in bankwire and similar payments. In bankwire is also currency changer built-in when more currencies are activated.

  • Like 2
Link to comment
Share on other sites

  • 4 weeks later...
  • 7 months later...

Hello!

I'm using prestashop in version 1.6.0.14. I have problem like others is this topic. I want to force change currency when client is changing language.

I must tell You that I tried solutions from this and others topics, but without any resoult. Maybe You know solution for that problem? 

 

 

EDIT: SOLVED! Don't know why, but I tried one more time with devein solution and it's working now, but don't know why... I have only strange bug that lang is not changing on first time, only after second click on it. (currency is changing on first click, lol ) 

Greetings!

Edited by Fertechpl (see edit history)
Link to comment
Share on other sites

  • 3 months later...
  • 2 weeks later...
  • 6 months later...
  • 3 weeks later...

in classes/Tools.php

for a quick fix just replace switchLanguage function with this one, making sure you edit the id's bellow with your own needs:

static public function switchLanguage()    {        global $cookie;        if ($id_lang = intval(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 = 2;  //change the currency too, the currency that has the id 2                    self::setCurrency();                    break;                case 2: //and so on ....                    $cookie->id_currency = 1;                    self::setCurrency();                    break;                case 3:                     $cookie->id_currency = 1;                    self::setCurrency();                    break;                case 4:                    $cookie->id_currency = 4;                    self::setCurrency();                    break;            }        }    }

Hi there,

 

Has anyone solved this for v1.6.1.5? thanks a lot! 

  • Like 1
Link to comment
Share on other sites

  • 8 months later...

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

  • 4 weeks later...

in classes/Tools.php

for a quick fix just replace switchLanguage function with this one, making sure you edit the id's bellow with your own needs:

static public function switchLanguage()    {        global $cookie;        if ($id_lang = intval(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 = 2;  //change the currency too, the currency that has the id 2                    self::setCurrency();                    break;                case 2: //and so on ....                    $cookie->id_currency = 1;                    self::setCurrency();                    break;                case 3:                     $cookie->id_currency = 1;                    self::setCurrency();                    break;                case 4:                    $cookie->id_currency = 4;                    self::setCurrency();                    break;            }        }    }

and how to change language automatically when default currency being set to mexican dollar prestashop 1.6.1.11 multishop with effecting shop URL  i,s .en and /sp 

Link to comment
Share on other sites

  • 11 months later...

For users which came from google to your localized site it's possible to set currency like this by edit function setCurrency($cookie) in /classes/Tools.php
this set currency for unkown people

Example if some guest came to

1) www.yoursite.com/cs/ = CZK currency
2) www.yoursite.com/pl/ = PLN currency
3) other will have default currency

    public static function setCurrency($cookie)
    {
        if (Tools::isSubmit('SubmitCurrency') && ($id_currency = Tools::getValue('id_currency'))) {
            /** @var Currency $currency */
            $currency = Currency::getCurrencyInstance((int)$id_currency);
            if (is_object($currency) && $currency->id && !$currency->deleted && $currency->isAssociatedToShop()) {
                $cookie->id_currency = (int)$currency->id;
            }
        }

        $currency = null;
        if ((int)$cookie->id_currency) {
            $currency = Currency::getCurrencyInstance((int)$cookie->id_currency);
        }
        if (!Validate::isLoadedObject($currency) || (bool)$currency->deleted || !(bool)$currency->active) {
          if ((int)$cookie->id_lang) {
              $currency_by_lang_id = Language::getIsoById((int)$cookie->id_lang);
              switch ($currency_by_lang_id){
                case 'cs':
                $currency_by_lang_iso_code = Currency::getIdByIsoCode('CZK');
                $currency = Currency::getCurrencyInstance((int)$currency_by_lang_iso_code);
                break;
                
                case 'pl':
                $currency_by_lang_iso_code = Currency::getIdByIsoCode('PLN');
                $currency = Currency::getCurrencyInstance((int)$currency_by_lang_iso_code);
                break;
                
                default:
                $currency = Currency::getCurrencyInstance(Configuration::get('PS_CURRENCY_DEFAULT'));
              }
          }
          else{
            $currency = Currency::getCurrencyInstance(Configuration::get('PS_CURRENCY_DEFAULT'));
          }
        }

        $cookie->id_currency = (int)$currency->id;
        if ($currency->isAssociatedToShop()) {
            return $currency;
        } else {
            // get currency from context
            $currency = Shop::getEntityIds('currency', Context::getContext()->shop->id, true, true);
            if (isset($currency[0]) && $currency[0]['id_currency']) {
                $cookie->id_currency = $currency[0]['id_currency'];
                return Currency::getCurrencyInstance((int)$cookie->id_currency);
            }
        }

        return $currency;
    }

Tested on Prestashop 1.6.17 & Working

Link to comment
Share on other sites

  • 3 years later...
  • 9 months later...

On PrestaShop version: 1.7.8.0, this is how you would more or like to achieve the goal based on the original answer 👇

Keep in mind that you should take advantage of overrides when overriding default behaviors. Hence the code would go to overrides/classes/Tools.php

    /**
     * If necessary change cookie language ID and context language.
     *
     * @param Context|null $context
     *
     * @throws PrestaShopDatabaseException
     * @throws PrestaShopException
     */
    public static function switchLanguage(Context $context = null)
    {
        if (null === $context) {
            $context = Context::getContext();
        }

        // On PrestaShop installations Dispatcher::__construct() gets called (and so Tools::switchLanguage())
        // Stop in this case by checking the cookie
        if (!isset($context->cookie)) {
            return;
        }

        if (
            ($iso = Tools::getValue('isolang')) &&
            Validate::isLanguageIsoCode($iso) &&
            ($id_lang = (int) Language::getIdByIso($iso))
        ) {
            $_GET['id_lang'] = $id_lang;
        }

        // Only switch if new ID is different from old ID
        $newLanguageId = (int) Tools::getValue('id_lang');

        if (
            Validate::isUnsignedId($newLanguageId) &&
            $newLanguageId !== 0 &&
            $context->cookie->id_lang !== $newLanguageId
        ) {
            $context->cookie->id_lang = $newLanguageId;
            $language = new Language($newLanguageId);
            if (Validate::isLoadedObject($language) && $language->active && $language->isAssociatedToShop()) {
                $context->language = $language;
            }
        }

        /** This is the switch we added to match language ID to a desired currency ID */
        switch($newLanguageId) {
            case 1: //if lang_id that's changed to is = 1 than...
                $context->cookie->id_currency = 2;  //change the currency too, the currency that has the id 2
                break;
            case 2: //and so on ....
                $context->cookie->id_currency = 1;
                break;
            case 3:
                $context->cookie->id_currency = 1;
                break;
            case 4:
                $context->cookie->id_currency = 4;
                break;
            default:
                $context->cookie->id_currency = 1;
        }
        
        Tools::setCookieLanguage($context->cookie);

        /** This is the function that actually sets the currency */
        Tools::setCurrency($context->cookie);
    }

 

Edited by senso321 (see edit history)
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...