MatiPasio Posted February 21, 2016 Share Posted February 21, 2016 (edited) Hello. I saw this post on the forum. https://www.prestashop.com/forums/topic/170209-how-can-i-publish-the-price-in-2-different-currencies-at-same-time/?p=1769361 And I tried implement a code with my modification. Function: public static function ConvertPrice($value,$currencyFrom,$currencyTo){ $currency_from = new currency($currencyFrom); $currency_to = new Currency($currencyTo); include_once(_PS_GEOIP_DIR_.'geoipcity.inc'); $gi = geoip_open(realpath(_PS_GEOIP_DIR_.'GeoLiteCity.dat'), GEOIP_STANDARD); $record = geoip_record_by_addr($gi, Tools::getRemoteAddr()); $country = $record->country_name; $this->context->smarty->assign('countryname', $country); return Tools::displayPrice(Tools::convertPriceFull($value,$currency_from,$currency_to),$currency_to); } But I've got a fatal error linked with $this->context->smarty->assign('countryname', $country); Using $this when not in object context in /xxx/xxx/xxx/classes/controller/FrontController.php on line 1695 What is wrong with this code? Edited February 21, 2016 by MatiPasio (see edit history) Link to comment Share on other sites More sharing options...
bellini13 Posted February 21, 2016 Share Posted February 21, 2016 This is a static function, so you cannot use $this. It is a poor design decision to have this static function add something to smarty. You should refactor this 1 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