[email protected] Posted May 20, 2016 Share Posted May 20, 2016 Hello, I´m trying to solve following issue. I have bought certain GeoIp redirect module. We´ve tested more of them and I found this one much faster and easier than others, we´ve made also many custom edits eg. we use geo country to display some additional info to customer and so on, it´s all working great... But after all these upgraded we found issue... When we set currency with $this->context->cookie->id_currency='XXXX' and then exec: Tools::setCurrency(); It works great after aditional page refresh. But when customer comes to category page from external link/campaign, he sees prices in default currency and then after page refresh in "redirected currency" (desirable one). I found out that its because module is executed too late - in display header... My question is - is there any easy way to run certain module in FrontController init() for example? Or do I have to manage it via hooks somehow? I suppose that when I set currency cookie early enough, it should solve my problem... Any help or hints would be so appreciated (send me Paypal acount, I´ll get you a coffee ) Martin Link to comment Share on other sites More sharing options...
[email protected] Posted May 22, 2016 Author Share Posted May 22, 2016 Well, I did not, my bad, thanks for reminding Anyway, this did not help. I suppose the problem is caused by the fact that geo module is runned "too late" - in hook Header. I´m not sure, but i suppose that currency to be used on loaded page is proccesed much earlier. Thats why after additional reload everything is OK. When i echo $cookie->id_currency and $currency->id they are different when this problem occures... I think that running this geostuff on FrontControllers´ init would help, or maybe I´m going to modify product controller to check if $cookie->id_currency and $currency->id are same and if not, then to use the one i need... Link to comment Share on other sites More sharing options...
[email protected] Posted May 23, 2016 Author Share Posted May 23, 2016 I´m gonna try it... So far I solved it like this: modified function displayPrice() in Tools.php to get currency formating: $cookie = Context::getContext()->cookie; $id_currency = $cookie->id_currency; $currency = Currency::getCurrencyInstance($id_currency); instead of if ($currency === null) $currency = $context->currency; elseif (is_int($currency)) $currency = Currency::getCurrencyInstance((int)$currency); and getPriceStatic() in Product.php $cookie = Context::getContext()->cookie; $id_currency = $cookie->id_currency; instead of $id_currency = (int)Validate::isLoadedObject($context->currency) ? $context->currency->id : Configuration::get('PS_CURRENCY_DEFAULT'); It seems to work fine, but I need to do some more research if it can possibly cause some other problems.... 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