sbhard Posted May 22, 2012 Share Posted May 22, 2012 how can i do something like this?i mean, how can i show 2 different currencies at same time in one article?Thank you for your answers! SOLVED! i decided to use vekia's module: show price in many currencies. Mainly because of fact that it works well with quantity discounts (when i increase / decrease quantity of product) and combinations that affects price. Link to comment Share on other sites More sharing options...
galactic Posted September 26, 2012 Share Posted September 26, 2012 I am also interested to show price in two currencies, a very handy and a necessary option. Link to comment Share on other sites More sharing options...
math_php Posted September 27, 2012 Share Posted September 27, 2012 Hi If you need it only in product page you have to make an override of ProductController and a light modification of product.tpl There is also a standard currency switch module. Regards Link to comment Share on other sites More sharing options...
math_php Posted September 27, 2012 Share Posted September 27, 2012 Hi again Create this file override/controllers/ProductController.php Put this code in the file : <?php class ProductController extends ProductControllerCore{ public function displayContent() { global $currency; $second_currency = 'USD'; $productPriceWithTax = Product::getPriceStatic($this->product->id, true, NULL, 6); if (Product::$_taxCalculationMethod == PS_TAX_INC) $productPriceWithTax = Tools::ps_round($productPriceWithTax, 2); $productPriceWithoutEcoTax = (float)($productPriceWithTax - $this->product->ecotax); $current_currency = $currency->iso_code; $default_currency = Currency::getDefaultCurrency()->iso_code; $currency_array = Currency::getCurrencies($object = false, $active = 1); if ($current_currency == $default_currency){ foreach ($currency_array as $arr){ if ((string)$arr['iso_code'] == $second_currency ){ $second_currency_price = Tools::ps_round($productPriceWithoutEcoTax * (float)$arr['conversion_rate'],2); } } } self::$smarty->assign('second_currency_price',$second_currency_price.' '.$second_currency); parent::displayContent(); } } In product.tpl modify {if $priceDisplay >= 0 && $priceDisplay <= 2} <span id="our_price_display">{convertPrice price=$productPrice}</span> To {if $priceDisplay >= 0 && $priceDisplay <= 2} {$second_currency_price}/ <span id="our_price_display">{convertPrice price=$productPrice}</span> I choosed USD to be the second currency ($second_currency='USD') , I have then this display 349.02 USD/ 259,53 € TTC. Regards Make backup before modifications. Link to comment Share on other sites More sharing options...
kindous Posted October 23, 2012 Share Posted October 23, 2012 Hello, i did everything in your manual. But the second price didint show up. In my case is default currency set to USD but i also want to see CZK. Does anybody know what is wrong?:/ Help is welcome. Thanks. Link to comment Share on other sites More sharing options...
BankiR Posted March 20, 2013 Share Posted March 20, 2013 (edited) Hi, problem modifications, presta 1.4.10 Error code: Undefined variable: second_currency_price (/home/itcontrol/www/test.com/override/controllers/ProductController.php, line 25)[/left] Help edit modif code Edited March 20, 2013 by BankiR (see edit history) Link to comment Share on other sites More sharing options...
math_php Posted March 20, 2013 Share Posted March 20, 2013 Hi, Check if $ sign is not missing in line 25 (if you made modification) Regards Link to comment Share on other sites More sharing options...
Paul C Posted March 21, 2013 Share Posted March 21, 2013 (edited) A simpler way might be to use the smarty modifier "convertAndFormatPrice". It takes two parameters: the price and the id of a currency. You'll need to know the id of the currency you want to use as the second one, but that shouldn't be too hard to figure out.... The format for modifiers is: {$first_param|modifier-name:param2:param3:....} It would appear that all you need to do is use the following in your template: {if $priceDisplay >= 0 && $priceDisplay <= 2} <span id="our_price_display">{$productPrice|convertAndFormatPrice:2}/{convertPrice price=$productPrice}</span> The above assumes that you non-default currency has an id of '2'. EDIT: Sadly the function used in my original attempt only changes the currency display and not the actual price it would seem.... modified the code which should work now.... Edited March 21, 2013 by Paul C (see edit history) Link to comment Share on other sites More sharing options...
BankiR Posted March 23, 2013 Share Posted March 23, 2013 Ok. And how can you make a category, recommended and other pages of a site? Link to comment Share on other sites More sharing options...
galactic Posted June 3, 2013 Share Posted June 3, 2013 (edited) Hi again Create this file override/controllers/ProductController.php Put this code in the file : <?php class ProductController extends ProductControllerCore{ public function displayContent() { global $currency; $second_currency = 'USD'; $productPriceWithTax = Product::getPriceStatic($this->product->id, true, NULL, 6); if (Product::$_taxCalculationMethod == PS_TAX_INC) $productPriceWithTax = Tools::ps_round($productPriceWithTax, 2); $productPriceWithoutEcoTax = (float)($productPriceWithTax - $this->product->ecotax); $current_currency = $currency->iso_code; $default_currency = Currency::getDefaultCurrency()->iso_code; $currency_array = Currency::getCurrencies($object = false, $active = 1); if ($current_currency == $default_currency){ foreach ($currency_array as $arr){ if ((string)$arr['iso_code'] == $second_currency ){ $second_currency_price = Tools::ps_round($productPriceWithoutEcoTax * (float)$arr['conversion_rate'],2); } } } self::$smarty->assign('second_currency_price',$second_currency_price.' '.$second_currency); parent::displayContent(); } } In product.tpl modify {if $priceDisplay >= 0 && $priceDisplay <= 2} <span id="our_price_display">{convertPrice price=$productPrice}</span> To {if $priceDisplay >= 0 && $priceDisplay <= 2} {$second_currency_price}/ <span id="our_price_display">{convertPrice price=$productPrice}</span> I choosed USD to be the second currency ($second_currency='USD') , I have then this display 349.02 USD/ 259,53 € TTC. Regards Make backup before modifications. Hi, can you show how will look this code for PS 1.5.4.x? Edited June 4, 2013 by galactic (see edit history) Link to comment Share on other sites More sharing options...
Admin@s Posted February 2, 2014 Share Posted February 2, 2014 Hi all I was looking for solution to display dual currency in PrestaShop - its actual for European Union countries who changes national currency to Euro and must display prices at least half year before and after in TWO currencies - national and Eur. After reading topics I was trying other metods but nothing works. And after all I found super simple solution - no changes to controllers or so: Just add: | €{round($productPrice*0.2896, 2)} After: <span id="our_price_display">{convertPrice price=$productPrice}</span> In: product.tpl You just need to change RATE of national currency to other currency. In my case its LTL:EUR=0.2896 Thats it 3 Link to comment Share on other sites More sharing options...
darkamarka Posted June 10, 2014 Share Posted June 10, 2014 But this doesn't work when product has combinations. Link to comment Share on other sites More sharing options...
darkamarka Posted June 10, 2014 Share Posted June 10, 2014 A simpler way might be to use the smarty modifier "convertAndFormatPrice". It takes two parameters: the price and the id of a currency. You'll need to know the id of the currency you want to use as the second one, but that shouldn't be too hard to figure out.... The format for modifiers is: {$first_param|modifier-name:param2:param3:....} It would appear that all you need to do is use the following in your template: {if $priceDisplay >= 0 && $priceDisplay <= 2} <span id="our_price_display">{$productPrice|convertAndFormatPrice:2}/{convertPrice price=$productPrice}</span>The above assumes that you non-default currency has an id of '2'. EDIT: Sadly the function used in my original attempt only changes the currency display and not the actual price it would seem.... modified the code which should work now.... But this doesn't work when product has combinations Link to comment Share on other sites More sharing options...
Silmari Posted August 9, 2014 Share Posted August 9, 2014 Hi all I was looking for solution to display dual currency in PrestaShop - its actual for European Union countries who changes national currency to Euro and must display prices at least half year before and after in TWO currencies - national and Eur. After reading topics I was trying other metods but nothing works. And after all I found super simple solution - no changes to controllers or so This solution worked great but only added a second currency to product details page. Frontpage still has default currency. Any ideas what to change in order to add a second currency on product list, in a cart and so on? Link to comment Share on other sites More sharing options...
aid-a Posted August 19, 2014 Share Posted August 19, 2014 I would also be grateful if someone could answer this question about 2 currencies at the same time (It's for European Union law to have 2 currencies). Maybe there is a module for this for those who do not know how to code? Thanks Link to comment Share on other sites More sharing options...
vekia Posted August 19, 2014 Share Posted August 19, 2014 public static function ConvertPrice($value,$currencyFrom,$currencyTo){ $currency_from = new currency($currencyFrom); $currency_to = new Currency($currencyTo); return Tools::displayPrice(Tools::convertPriceFull($value,$currency_from,$currency_to),$currency_to); } use this in classes/controllers/frontController.php then in template file use: (in product-list.tpl) {convertPrice price=FrontController::ConvertPrice($product.price,$cookie->id_currency,2)} in product.tpl {convertPrice price=FrontController::ConvertPrice($product->price,$cookie->id_currency,2)} 2 is an id of currency you want to display. Please note that this modification does not change the value of second price if you will switch an attribute! (for example if your attribute has a price impact) module that works well with attributes change and quantitiy discount is here show price in 2 different currencies Link to comment Share on other sites More sharing options...
aid-a Posted August 19, 2014 Share Posted August 19, 2014 So I should change this one below to yours? public static function getCurrentCustomerGroups() { if (!Group::isFeatureActive()) return array(); $context = Context::getContext(); if (!isset($context->customer) || !$context->customer->id) return array(); if (!is_array(self::$currentCustomerGroups)) { self::$currentCustomerGroups = array(); $result = Db::getInstance()->executeS('SELECT id_group FROM '._DB_PREFIX_.'customer_group WHERE id_customer = '.(int)$context->customer->id); foreach ($result as $row) self::$currentCustomerGroups[] = $row['id_group']; } return self::$currentCustomerGroups;Where (which line and wether do I delete sth or overwrite) do I put this code?in template file use: (in product-list.tpl) {convertPrice price=FrontController::ConvertPrice($product.price,$cookie->id_currency,2)}And this: in product.tpl {convertPrice price=FrontController::ConvertPrice($product->price,$cookie->id_currency,2)} 2 is an id of currency you want to display.Thanks! Link to comment Share on other sites More sharing options...
vekia Posted August 19, 2014 Share Posted August 19, 2014 in controller (frontController.php) you can: - create an override or just change original file, paste function: public static function ConvertPrice($value,$currencyFrom,$currencyTo){ $currency_from = new currency($currencyFrom); $currency_to = new Currency($currencyTo); return Tools::displayPrice(Tools::convertPriceFull($value,$currency_from,$currency_to),$currency_to); } before last closing bracket. then you will be able to use smarty code: {convertPrice price=FrontController::ConvertPrice($product->price,$cookie->id_currency,2)} there, where you want to display other currency price Link to comment Share on other sites More sharing options...
Silmari Posted August 19, 2014 Share Posted August 19, 2014 Thanks a lot, vekia! It helped Link to comment Share on other sites More sharing options...
vekia Posted August 19, 2014 Share Posted August 19, 2014 you're welcome ;-) glad to hear that i could help i saw a lot topics related to this problem so i decided to write solution :-) with regards, Milos Link to comment Share on other sites More sharing options...
oracle178 Posted August 20, 2014 Share Posted August 20, 2014 But this doesn't work when product has combinations with different prices second currency does not change Link to comment Share on other sites More sharing options...
tikis Posted August 20, 2014 Share Posted August 20, 2014 in controller (frontController.php) you can: - create an override or just change original file, paste function: public static function ConvertPrice($value,$currencyFrom,$currencyTo){ $currency_from = new currency($currencyFrom); $currency_to = new Currency($currencyTo); return Tools::displayPrice(Tools::convertPriceFull($value,$currency_from,$currency_to),$currency_to); } before last closing bracket. then you will be able to use smarty code: {convertPrice price=FrontController::ConvertPrice($product->price,$cookie->id_currency,2)} there, where you want to display other currency price when i do all and upload to server my site is down, not showing , only shows white list, wish solutions? Link to comment Share on other sites More sharing options...
3oh3 Posted August 23, 2014 Share Posted August 23, 2014 when i do all and upload to server my site is down, not showing , only shows white list, wish solutions? Well sad to say, but i have same issue. Where did i go wrong with this? Have no clue about it... Link to comment Share on other sites More sharing options...
gadnis Posted September 1, 2014 Share Posted September 1, 2014 Smarty code works. I works great in product.tpl but in the product-list.tpl not really. I can see only $0.00 next to all listed products original price. Here is how I pasted the smarty code: <a class="quick-view" href="{$product.link|escape:'html':'UTF-8'}" rel="{$product.link|escape:'html':'UTF-8'}"> <span>{l s='Quick view'}</span> </a> {/if} {if (!$PS_CATALOG_MODE AND ((isset($product.show_price) && $product.show_price) || (isset($product.available_for_order) && $product.available_for_order)))} <div class="content_price" itemprop="offers" itemscope itemtype="http://schema.org/Offer"> {if isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)} <span itemprop="price" class="price product-price"> {if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if} <!-- EDVINAS keiciam ir cia valiuta i dvi valiutas QUICK VIEW vieta--> <font size="2">|{convertPrice price=FrontController::ConvertPrice($product->price,$cookie->id_currency,1)}</font> <!-- Edvinas. --> </span> <meta itemprop="priceCurrency" content="{$currency->iso_code}" /> {if isset($product.specific_prices) && $product.specific_prices && isset($product.specific_prices.reduction) && $product.specific_prices.reduction > 0} {hook h="displayProductPriceBlock" product=$product type="old_price"} <span class="old-price product-price"> {displayWtPrice p=$product.price_without_reduction} </span> {if $product.specific_prices.reduction_type == 'percentage'} <span class="price-percent-reduction">-{$product.specific_prices.reduction * 100}%</span> {/if} {/if} {hook h="displayProductPriceBlock" product=$product type="price"} {hook h="displayProductPriceBlock" product=$product type="unit_price"} {/if} </div> {/if} in controller (frontController.php) you can: - create an override or just change original file, paste function: public static function ConvertPrice($value,$currencyFrom,$currencyTo){ $currency_from = new currency($currencyFrom); $currency_to = new Currency($currencyTo); return Tools::displayPrice(Tools::convertPriceFull($value,$currency_from,$currency_to),$currency_to); } before last closing bracket. then you will be able to use smarty code: {convertPrice price=FrontController::ConvertPrice($product->price,$cookie->id_currency,2)} there, where you want to display other currency price Link to comment Share on other sites More sharing options...
vekia Posted September 1, 2014 Share Posted September 1, 2014 product-list.tpl use $product as an array not as an object it means taht in product-list.tpl you have to use $product.price instead of $product->price Link to comment Share on other sites More sharing options...
gadnis Posted September 1, 2014 Share Posted September 1, 2014 product-list.tpl use $product as an array not as an object it means taht in product-list.tpl you have to use $product.price instead of $product->price Thanks Link to comment Share on other sites More sharing options...
gadnis Posted September 1, 2014 Share Posted September 1, 2014 one more question.. Tax is included in all prices but not in second price on product page... is it possible to fix some how this? product-list.tpl use $product as an array not as an object it means taht in product-list.tpl you have to use $product.price instead of $product->price Thanks Link to comment Share on other sites More sharing options...
oracle178 Posted September 2, 2014 Share Posted September 2, 2014 on product page you can use $productPrice or $productPriceWithoutReduction Link to comment Share on other sites More sharing options...
vekia Posted September 2, 2014 Share Posted September 2, 2014 one more question.. Tax is included in all prices but not in second price on product page... is it possible to fix some how this? on product page you can use $productPrice or $productPriceWithoutReduction reductions means taxes in this case? Link to comment Share on other sites More sharing options...
oracle178 Posted September 3, 2014 Share Posted September 3, 2014 no, there is how I changed smarty to display two curencies on product page (product.tpl) <p class="our_price_display"> {if $priceDisplay >= 0 && $priceDisplay <= 2} <span id="our_price_display" class="price">{convertPrice price=$productPrice}</span> <span style="color:#c60200; font-size:16px;"> / </span> <span id="our_price_display_eu" class="price">{($productPrice * $currencies[0].conversion_rate)|round:"2"}</span> <span style="color:#c60200; font-size:16px;">{l s='eu'}</span> {if $tax_enabled && ((isset($display_tax_label) && $display_tax_label == 1) OR !isset($display_tax_label))} {if $priceDisplay == 1}{l s='tax excl.'}{else}{l s='tax incl.'}{/if} {/if} {/if} </p> I also modify product.js $('#our_price_display').text(our_price); $('#our_price_display_eu').text(Number(our_price_eu / 3.4528).toFixed(2)); $('#old_price_display').text(formatCurrency(productPriceWithoutReduction, currencyFormat, currencySign, currencyBlank)); $('#old_price_display_eu').text(Number(productPriceWithoutReduction / 3.4528).toFixed(2)); 3.4528 is the official exchange rate, and in this way it works when there are several combinations of products. sorry for my English Link to comment Share on other sites More sharing options...
oracle178 Posted September 3, 2014 Share Posted September 3, 2014 You can see how it works in http://www.zvejoklis.lt/ 1 Link to comment Share on other sites More sharing options...
ixiux Posted September 10, 2014 Share Posted September 10, 2014 no, there is how I changed smarty to display two curencies on product page (product.tpl) <p class="our_price_display"> {if $priceDisplay >= 0 && $priceDisplay <= 2} <span id="our_price_display" class="price">{convertPrice price=$productPrice}</span> <span style="color:#c60200; font-size:16px;"> / </span> <span id="our_price_display_eu" class="price">{($productPrice * $currencies[0].conversion_rate)|round:"2"}</span> <span style="color:#c60200; font-size:16px;">{l s='eu'}</span> {if $tax_enabled && ((isset($display_tax_label) && $display_tax_label == 1) OR !isset($display_tax_label))} {if $priceDisplay == 1}{l s='tax excl.'}{else}{l s='tax incl.'}{/if} {/if} {/if} </p> I also modify product.js $('#our_price_display').text(our_price); $('#our_price_display_eu').text(Number(our_price_eu / 3.4528).toFixed(2)); $('#old_price_display').text(formatCurrency(productPriceWithoutReduction, currencyFormat, currencySign, currencyBlank)); $('#old_price_display_eu').text(Number(productPriceWithoutReduction / 3.4528).toFixed(2)); 3.4528 is the official exchange rate, and in this way it works when there are several combinations of products. sorry for my English Does all you change was product.tpl and product.js? I try the same, but nothing happen. Link to comment Share on other sites More sharing options...
gadnis Posted September 10, 2014 Share Posted September 10, 2014 Hi, Vekia, Your method works fine. Just two things not exactly: 1. in product page EURO price is calculated without taxes (I am using retail price without taxes, and added a 21% VAT tax rule for every product. For customers who must pay taxes (VAT) the price in my currency is shown right - including taxes. But in euros the price is shown excluding taxes - VAT) 2. The calculated price should be round to decimals after comma. For example 125 Lt should be shown as 36.20 EUR. But instead it's shown 36 EUR. p.s. I hope I have written quite understandable. Thanks for any help. in controller (frontController.php) you can: - create an override or just change original file, paste function: public static function ConvertPrice($value,$currencyFrom,$currencyTo){ $currency_from = new currency($currencyFrom); $currency_to = new Currency($currencyTo); return Tools::displayPrice(Tools::convertPriceFull($value,$currency_from,$currency_to),$currency_to); } before last closing bracket. then you will be able to use smarty code: {convertPrice price=FrontController::ConvertPrice($product->price,$cookie->id_currency,2)} there, where you want to display other currency price Link to comment Share on other sites More sharing options...
gadnis Posted September 11, 2014 Share Posted September 11, 2014 (edited) EDIT: oh my gush.. I've just got it how the smarty code works.. I was so stupid.. sorry. Everything works perfect. You just need to find places where to add the smarty code and change what price you want to convert. Smarty code: {convertPrice price=FrontController::ConvertPrice($productPrice,$cookie->id_currency,3)} $productPrice is a product price tax included $cookie-id_currency - no worries about it, just don't change it number 3 is a currency you want to see and now.. If you want to see lets say shopping cart total price, change the $productPrice to $product.total_wt. I don't know how these things is called (maybe Vieka could tell us) but you can find them already on the code just use your brains if you don't know the code, experiment.. OLD: 2. problem I solved going to currencies and turning on to show the decimals. Hi, Vekia, Your method works fine. Just two things not exactly: 1. in product page EURO price is calculated without taxes (I am using retail price without taxes, and added a 21% VAT tax rule for every product. For customers who must pay taxes (VAT) the price in my currency is shown right - including taxes. But in euros the price is shown excluding taxes - VAT) 2. The calculated price should be round to decimals after comma. For example 125 Lt should be shown as 36.20 EUR. But instead it's shown 36 EUR. p.s. I hope I have written quite understandable. Thanks for any help. Edited September 11, 2014 by gadnis (see edit history) Link to comment Share on other sites More sharing options...
moraira Posted September 19, 2014 Share Posted September 19, 2014 Vekia es el puto amo... oh sorry, this is an english post... Vekia, like a boss Link to comment Share on other sites More sharing options...
moraira Posted September 23, 2014 Share Posted September 23, 2014 public static function ConvertPrice($value,$currencyFrom,$currencyTo){ $currency_from = new currency($currencyFrom); $currency_to = new Currency($currencyTo); return Tools::displayPrice(Tools::convertPriceFull($value,$currency_from,$currency_to),$currency_to); } use this in classes/controllers/frontController.php then in template file use: (in product-list.tpl) {convertPrice price=FrontController::ConvertPrice($product.price,$cookie->id_currency,2)} in product.tpl {convertPrice price=FrontController::ConvertPrice($product->price,$cookie->id_currency,2)} 2 is an id of currency you want to display. hi vekia I am using it in shopping-cart.tpl, and I found this problem: {if $cookie->id_currency != 1} <span>({displayPrice price=FrontController::ConvertPrice($total_price,$cookie->id_currency,1)})</span> {/if} if 1 pound is 0.787600 euros then 56 euros are 44,10 pounds but 44,10 pounds are 55,99 euros when I see total shopping cart in pounds the second price is 55,99 euros, not 56 Link to comment Share on other sites More sharing options...
LamantasirKO Posted October 1, 2014 Share Posted October 1, 2014 Good morning I try Vekia code, its working, but when i go from HP to am products or something else prices are different In home page for e.g Greita peržiūra1 199,96 LT |€ 347.53 right price. But when i click and redirect inside this product i see this 1 199,96 LT |€ 287.21. Any sugestions ? UP@!@ Link to comment Share on other sites More sharing options...
tikis Posted October 1, 2014 Share Posted October 1, 2014 Hi again Create this file override/controllers/ProductController.php Put this code in the file : <?php class ProductController extends ProductControllerCore{ public function displayContent() { global $currency; $second_currency = 'USD'; $productPriceWithTax = Product::getPriceStatic($this->product->id, true, NULL, 6); if (Product::$_taxCalculationMethod == PS_TAX_INC) $productPriceWithTax = Tools::ps_round($productPriceWithTax, 2); $productPriceWithoutEcoTax = (float)($productPriceWithTax - $this->product->ecotax); $current_currency = $currency->iso_code; $default_currency = Currency::getDefaultCurrency()->iso_code; $currency_array = Currency::getCurrencies($object = false, $active = 1); if ($current_currency == $default_currency){ foreach ($currency_array as $arr){ if ((string)$arr['iso_code'] == $second_currency ){ $second_currency_price = Tools::ps_round($productPriceWithoutEcoTax * (float)$arr['conversion_rate'],2); } } } self::$smarty->assign('second_currency_price',$second_currency_price.' '.$second_currency); parent::displayContent(); } } In product.tpl modify {if $priceDisplay >= 0 && $priceDisplay <= 2} <span id="our_price_display">{convertPrice price=$productPrice}</span> To {if $priceDisplay >= 0 && $priceDisplay <= 2} {$second_currency_price}/ <span id="our_price_display">{convertPrice price=$productPrice}</span> I choosed USD to be the second currency ($second_currency='USD') , I have then this display 349.02 USD/ 259,53 € TTC. Regards Make backup before modifications. Hi again Create this file override/controllers/ProductController.php Put this code in the file : <?php class ProductController extends ProductControllerCore{ public function displayContent() { global $currency; $second_currency = 'USD'; $productPriceWithTax = Product::getPriceStatic($this->product->id, true, NULL, 6); if (Product::$_taxCalculationMethod == PS_TAX_INC) $productPriceWithTax = Tools::ps_round($productPriceWithTax, 2); $productPriceWithoutEcoTax = (float)($productPriceWithTax - $this->product->ecotax); $current_currency = $currency->iso_code; $default_currency = Currency::getDefaultCurrency()->iso_code; $currency_array = Currency::getCurrencies($object = false, $active = 1); if ($current_currency == $default_currency){ foreach ($currency_array as $arr){ if ((string)$arr['iso_code'] == $second_currency ){ $second_currency_price = Tools::ps_round($productPriceWithoutEcoTax * (float)$arr['conversion_rate'],2); } } } self::$smarty->assign('second_currency_price',$second_currency_price.' '.$second_currency); parent::displayContent(); } } In product.tpl modify {if $priceDisplay >= 0 && $priceDisplay <= 2} <span id="our_price_display">{convertPrice price=$productPrice}</span> To {if $priceDisplay >= 0 && $priceDisplay <= 2} {$second_currency_price}/ <span id="our_price_display">{convertPrice price=$productPrice}</span> I choosed USD to be the second currency ($second_currency='USD') , I have then this display 349.02 USD/ 259,53 € TTC. Regards Make backup before modifications. i'am don't find this lines where changed it? i add my files from server, please see and ask me whats problem site is www.kvepinkis.lt http://speedy.sh/B6ED5/product.tpl http://speedy.sh/VRqHW/ProductController.php Link to comment Share on other sites More sharing options...
KubusPuchatek Posted October 27, 2014 Share Posted October 27, 2014 public static function ConvertPrice($value,$currencyFrom,$currencyTo){ $currency_from = new currency($currencyFrom); $currency_to = new Currency($currencyTo); return Tools::displayPrice(Tools::convertPriceFull($value,$currency_from,$currency_to),$currency_to); } use this in classes/controllers/frontController.php then in template file use: (in product-list.tpl) {convertPrice price=FrontController::ConvertPrice($product.price,$cookie->id_currency,2)} in product.tpl {convertPrice price=FrontController::ConvertPrice($product->price,$cookie->id_currency,2)} 2 is an id of currency you want to display. Could you offer a solution working in PrestaShop 1.4? Link to comment Share on other sites More sharing options...
Dzinyna Posted November 5, 2014 Share Posted November 5, 2014 It worked graet. public static function ConvertPrice($value,$currencyFrom,$currencyTo){ $currency_from = new currency($currencyFrom); $currency_to = new Currency($currencyTo); return Tools::displayPrice(Tools::convertPriceFull($value,$currency_from,$currency_to),$currency_to); } use this in classes/controllers/frontController.php then in template file use: (in product-list.tpl) {convertPrice price=FrontController::ConvertPrice($product.price,$cookie->id_currency,2)} in product.tpl {convertPrice price=FrontController::ConvertPrice($product->price,$cookie->id_currency,2)} 2 is an id of currency you want to display. But... combinations not working... I tried solution from #32 post, but it didn't work for me. Is there any one who found universal or some how working solution to make combinations work. Any help is welcome. Link to comment Share on other sites More sharing options...
vekia Posted November 7, 2014 Share Posted November 7, 2014 yes, combinations not working to create feature with working combinations price change it will be necessary to alter also js scripts i don't think so that it's an easy thing Link to comment Share on other sites More sharing options...
Dzinyna Posted November 7, 2014 Share Posted November 7, 2014 Thanks for your answer vekia. I can see it now, that is not an easy thing to make it work. Link to comment Share on other sites More sharing options...
tikis Posted November 8, 2014 Share Posted November 8, 2014 (edited) Create this file override/controllers/ProductController.phpPut this code in the file : <?phpclass ProductController extends ProductControllerCore{public function displayContent(){ global $currency; $second_currency = 'USD'; $productPriceWithTax = Product::getPriceStatic($this->product->id, true, NULL, 6);if (Product::$_taxCalculationMethod == PS_TAX_INC) $productPriceWithTax = Tools::ps_round($productPriceWithTax, 2);$productPriceWithoutEcoTax = (float)($productPriceWithTax - $this->product->ecotax); $current_currency = $currency->iso_code; $default_currency = Currency::getDefaultCurrency()->iso_code; $currency_array = Currency::getCurrencies($object = false, $active = 1); if ($current_currency == $default_currency){ foreach ($currency_array as $arr){ if ((string)$arr['iso_code'] == $second_currency ){ $second_currency_price = Tools::ps_round($productPriceWithoutEcoTax * (float)$arr['conversion_rate'],2); } } }self::$smarty->assign('second_currency_price',$second_currency_price.' '.$second_currency);parent::displayContent();}} In product.tpl modify{if $priceDisplay >= 0 && $priceDisplay <= 2} <span id="our_price_display">{convertPrice price=$productPrice}</span> To{if $priceDisplay >= 0 && $priceDisplay <= 2} {$second_currency_price}/ <span id="our_price_display">{convertPrice price=$productPrice}</span> I choosed USD to be the second currency ($second_currency='USD') , I have then this display 349.02 USD/ 259,53 € TTC.RegardsMake backup before modifications. math_php, on 27 Sept 2012 - 5:07 PM, said: Hi againCreate this file override/controllers/ProductController.phpPut this code in the file : <?phpclass ProductController extends ProductControllerCore{public function displayContent(){ global $currency; $second_currency = 'USD'; $productPriceWithTax = Product::getPriceStatic($this->product->id, true, NULL, 6);if (Product::$_taxCalculationMethod == PS_TAX_INC) $productPriceWithTax = Tools::ps_round($productPriceWithTax, 2);$productPriceWithoutEcoTax = (float)($productPriceWithTax - $this->product->ecotax); $current_currency = $currency->iso_code; $default_currency = Currency::getDefaultCurrency()->iso_code; $currency_array = Currency::getCurrencies($object = false, $active = 1); if ($current_currency == $default_currency){ foreach ($currency_array as $arr){ if ((string)$arr['iso_code'] == $second_currency ){ $second_currency_price = Tools::ps_round($productPriceWithoutEcoTax * (float)$arr['conversion_rate'],2); } } }self::$smarty->assign('second_currency_price',$second_currency_price.' '.$second_currency);parent::displayContent();}} In product.tpl modify{if $priceDisplay >= 0 && $priceDisplay <= 2} <span id="our_price_display">{convertPrice price=$productPrice}</span> To{if $priceDisplay >= 0 && $priceDisplay <= 2} {$second_currency_price}/ <span id="our_price_display">{convertPrice price=$productPrice}</span> I choosed USD to be the second currency ($second_currency='USD') , I have then this display 349.02 USD/ 259,53 € TTC.RegardsMake backup before modifications. i'am don't find this lines where changed it? i add my files from server, please see and ask me whats problem site is www.kvepinkis.lt http://speedy.sh/B6ED5/product.tpl http://speedy.sh/VRqHW/ProductController.php Edited November 8, 2014 by tikis (see edit history) Link to comment Share on other sites More sharing options...
Dzinyna Posted November 15, 2014 Share Posted November 15, 2014 (edited) Did you tikis try vekia solution (#40post)? it worked great for me to show two currencies. (beje, tie failai neprieinami pažiūrėti) Edited November 15, 2014 by Dzinyna (see edit history) Link to comment Share on other sites More sharing options...
GreddyMR2 Posted November 24, 2014 Share Posted November 24, 2014 (edited) Hi there, I am trying to do this thing as well, but can't work it out with product-list.tpl file. I managed to show two prices in product page, but can't make it with product list. I attach the picture and here is where I added the line: {foreach from=$products item=product name=products} {math equation="(total%perLine)" total=$smarty.foreach.products.total perLine=$nbItemsPerLine assign=totModulo} {math equation="(total%perLineT)" total=$smarty.foreach.products.total perLineT=$nbItemsPerLineTablet assign=totModuloTablet} {math equation="(total%perLineT)" total=$smarty.foreach.products.total perLineT=$nbItemsPerLineMobile assign=totModuloMobile} {if $totModulo == 0}{assign var='totModulo' value=$nbItemsPerLine}{/if} {if $totModuloTablet == 0}{assign var='totModuloTablet' value=$nbItemsPerLineTablet}{/if} {if $totModuloMobile == 0}{assign var='totModuloMobile' value=$nbItemsPerLineMobile}{/if} <div class="ajax_block_product col-sp-12 {$colValue}{if $smarty.foreach.products.iteration%$nbItemsPerLine == 0} last-in-line {elseif $smarty.foreach.products.iteration%$nbItemsPerLine == 1} first-in-line{/if} {if $smarty.foreach.products.iteration > ($smarty.foreach.products.total - $totModulo)} last-line{/if} {if $smarty.foreach.products.iteration%$nbItemsPerLineTablet == 0} last-item-of-tablet-line {elseif $smarty.foreach.products.iteration%$nbItemsPerLineTablet == 1} first-item-of-tablet-line{/if} {if $smarty.foreach.products.iteration%$nbItemsPerLineMobile == 0} last-item-of-mobile-line {elseif $smarty.foreach.products.iteration%$nbItemsPerLineMobile == 1} first-item-of-mobile-line{/if} {if $smarty.foreach.products.iteration > ($smarty.foreach.products.total - $totModuloMobile)} last-mobile-line {/if}"> {include file="$tpl_dir./product-item.tpl" callFromModule=isset($class)} {convertPrice price=FrontController::ConvertPrice($product.price,$cookie->id_currency,2)} </div> {/foreach} Edited November 24, 2014 by GreddyMR2 (see edit history) Link to comment Share on other sites More sharing options...
Vilna Posted November 30, 2014 Share Posted November 30, 2014 in controller (frontController.php) you can: - create an override or just change original file, paste function: public static function ConvertPrice($value,$currencyFrom,$currencyTo){ $currency_from = new currency($currencyFrom); $currency_to = new Currency($currencyTo); return Tools::displayPrice(Tools::convertPriceFull($value,$currency_from,$currency_to),$currency_to); } before last closing bracket. then you will be able to use smarty code: {convertPrice price=FrontController::ConvertPrice($product->price,$cookie->id_currency,2)} there, where you want to display other currency price Thank you Vekia, I have tried this code and it works perfectly for product-list.tpl, but I cannot find a place where to add this code on product.tpl? Could you help me, please, where to add this code so I could see my prices in 2 currencies at the same time? Link to comment Share on other sites More sharing options...
aliosman20 Posted January 30, 2015 Share Posted January 30, 2015 in controller (frontController.php) you can: - create an override or just change original file, paste function: public static function ConvertPrice($value,$currencyFrom,$currencyTo){ $currency_from = new currency($currencyFrom); $currency_to = new Currency($currencyTo); return Tools::displayPrice(Tools::convertPriceFull($value,$currency_from,$currency_to),$currency_to); } before last closing bracket. then you will be able to use smarty code: {convertPrice price=FrontController::ConvertPrice($product->price,$cookie->id_currency,2)} there, where you want to display other currency price Hi, I made modificaition as you said. But product_list.tpl files shows prices with tax included but product.tpl file shows prices without tax in currency after convert. I show to my customer all prices with tax in my shop. I use prestahop 1.6.9 and use default template. Example: price 29.50TRL(tax includeded) convert price 10.77$ in product_list.tpl file. but same product convert price is 9.97$ that is converted without tax price. Please help. Thanks Link to comment Share on other sites More sharing options...
fufaika Posted March 26, 2015 Share Posted March 26, 2015 Viskas yra labai paprasta, uztenka du failus modifikuoti ir visoje parduotuveje bus dvi kainos EUR ir LTL jei kam reikia daugiau info rasykite Link to comment Share on other sites More sharing options...
Vitazzz Posted August 28, 2015 Share Posted August 28, 2015 (edited) hi ppl, I've managed to add second currency to product.tpl and product-list.tpl so it is working. But for some reason it does not work at all in my blockcart.tpl file. I've tryed everything of this: $total, $shipping_cost, $products_wt, $order_total still only original price is displayed. I've tried clearing cache and cookies. Feels like there is some sort of access denial to Front Controller, but dunno. Edited August 28, 2015 by Vitazzz (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted August 30, 2015 Share Posted August 30, 2015 do you use variables (in block cart) that exists in available smarty variables array? Link to comment Share on other sites More sharing options...
johnhgaspay Posted February 26, 2016 Share Posted February 26, 2016 @vekia where you can add those line on your template? am using version 1.6.0.9 Link to comment Share on other sites More sharing options...
Tatort Posted May 16, 2017 Share Posted May 16, 2017 in controller (frontController.php) you can: - create an override or just change original file, paste function: public static function ConvertPrice($value,$currencyFrom,$currencyTo){ $currency_from = new currency($currencyFrom); $currency_to = new Currency($currencyTo); return Tools::displayPrice(Tools::convertPriceFull($value,$currency_from,$currency_to),$currency_to); } before last closing bracket. then you will be able to use smarty code: {convertPrice price=FrontController::ConvertPrice($product->price,$cookie->id_currency,2)} there, where you want to display other currency price Hello, it's seems to be not working on Prestashop 1.6 with specific price... I have a EUR price and a specific price pour US dollar... With your tricks the price displayed are the same... Did i miss something ? Thank Link to comment Share on other sites More sharing options...
TCS Posted May 19, 2018 Share Posted May 19, 2018 On 8/19/2014 at 3:55 AM, vekia said: public static function ConvertPrice($value,$currencyFrom,$currencyTo){ $currency_from = new currency($currencyFrom); $currency_to = new Currency($currencyTo); return Tools::displayPrice(Tools::convertPriceFull($value,$currency_from,$currency_to),$currency_to); } use this in classes/controllers/frontController.php then in template file use: (in product-list.tpl) {convertPrice price=FrontController::ConvertPrice($product.price,$cookie->id_currency,2)} in product.tpl {convertPrice price=FrontController::ConvertPrice($product->price,$cookie->id_currency,2)} 2 is an id of currency you want to display. Please note that this modification does not change the value of second price if you will switch an attribute! (for example if your attribute has a price impact) module that works well with attributes change and quantitiy discount is here show price in 2 different currencies Hi, We bought the module and it works well, but it does not swap the values if you select the secondary currency from the currency selector. Is ther a way to fix this issue? Regards, Link to comment Share on other sites More sharing options...
TCS Posted May 19, 2018 Share Posted May 19, 2018 On 5/21/2012 at 5:02 PM, sbhard said: how can i do something like this? i mean, how can i show 2 different currencies at same time in one article? Thank you for your answers! SOLVED! i decided to use vekia's module: show price in many currencies. Mainly because of fact that it works well with quantity discounts (when i increase / decrease quantity of product) and combinations that affects price. Hi, I also bought the module but wanted to ask if you also have a problem when you swap from primary currency to secondary currency? like my image shows. Regards, Link to comment Share on other sites More sharing options...
MCayirli Posted February 24, 2021 Share Posted February 24, 2021 On 8/19/2014 at 2:31 PM, vekia said: in controller (frontController.php) you can: - create an override or just change original file, paste function: public static function ConvertPrice($value,$currencyFrom,$currencyTo){ $currency_from = new currency($currencyFrom); $currency_to = new Currency($currencyTo); return Tools::displayPrice(Tools::convertPriceFull($value,$currency_from,$currency_to),$currency_to); } before last closing bracket. then you will be able to use smarty code: {convertPrice price=FrontController::ConvertPrice($product->price,$cookie->id_currency,2)} there, where you want to display other currency price It may be more effective to use ISO codes instead of using IDs in currencies. in controller (frontController.php) you can: public static function ConvertPrice($value,$currencyFrom,$currencyTo){ $currency_from = new Currency((int)Currency::getIdByIsoCode($currencyFrom)); $currency_to = new Currency((int)Currency::getIdByIsoCode($currencyTo)); return Tools::displayPrice(Tools::convertPriceFull($value,$currency_from,$currency_to),$currency_to); } then you will be able to use smarty code: {FrontController::ConvertPrice($product->price_amount,'USD','TRY')} there, where you want to display other currency price Link to comment Share on other sites More sharing options...
webseregas Posted August 18, 2021 Share Posted August 18, 2021 hi, there is a solution for version 1.7 ? Link to comment Share on other sites More sharing options...
Hamza ben jabeur Posted December 6, 2021 Share Posted December 6, 2021 On 8/18/2021 at 10:51 AM, webseregas said: hi, there is a solution for version 1.7 ? unfortuntly not yet ! 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