Jump to content

Presta 1.5.2.0 - Currencies are not refreshing when changing laguage


Recommended Posts

Hi, I have a strange problem. I have 2 lang versions in my shop - Polish and English. For polish currency is PLN and for English version EUR. Sometimes(not every time let's say 1 per 3 times) when I change lang versions(from EN to PL), the currency is not changing I mean:

-page lang is changing and I see text in Polish

-every rule for Polish version is working(e.g. if value of cart is higher than 500 PLN shipping is free)

But the problem is that my currency is still Euro - everything is in Polish, but for example I have 10 euro instead of 40 PLN. Do you have any suggestions how to solve it, 'cause it is quite problematic for me?

 

Presta 1.5.2, Ajax cart in use

 

I am using Block lang and Currencies and Languages by prestahelp.com

 

It seems that's the problem of Ajax, 'cause when page fully reloads currency is chaning, but when it's not fully refreshing currency is not getting changed.

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

I found the solution on forum so you can mark it as solved. I will put it here so other people will not strugle with that case. I am not author of code.

 

This works for 1.5.2 for sure. Just remove [THIS LINE ADDED] [/THIS LINE ADDED] and [THIS SECTION ADDED][/THIS SECTION ADDED]

 

File: controllers/front/ChangeCurrencyControler.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;
  [THIS LINE ADDED]$this->context->cookie->id_currency_changed = 1;[/THIS LINE ADDED]
   die('1');
  }
  die('0');
}
}

File: 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']);
	   
	  [THIS SECTION ADDED]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; 
	  } [/THIS SECTION ADDED]
  }
}
 
  [THIS SECTION ADDED]/**
  * 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;
    }
  }[/THIS SECTION ADDED]
Edited by satania (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...