Wie modifiziere ich PrestaShop 1.5 Produktpreise in zwei Währungen zur gleichen Zeit (. Dh Basis Currenct und Besucher Währung auf Produkte in der Produkt & Kategorien Seiten aufgeführt) anzuzeigen:Produktpreis in zwei Währungen gleichzeitig anzeigen?
Ich glaube, ich sollte bearbeite ProductController.php
und product.tpl
. Ist das richtig?
Im Folgenden finden Sie eine Lösung für die Produktseite, die ich auf einem Forum zu finden, aber es ist für PrestaShop 1.4x:
Aufschalten ProductController.php in /controllers/ProductController.php
<?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(); } }
Ändern
product.tpl
:{if $priceDisplay >= 0 && $priceDisplay <= 2} <span id="our_price_display">{convertPrice price=$productPrice}</span>
zu
{if $priceDisplay >= 0 && $priceDisplay <= 2} {$second_currency_price}/ <span id="our_price_display">{convertPrice price=$productPrice}</span>
Im obigen Beispiel USD ist die zweite Währung ($second_currency='USD'
). Ich habe mich gefragt, ob es möglich wäre, diesen Code für PrestaShop 1.5 zu ändern, der sich seit 1.4x erheblich geändert hat.
Ich fügte meiner Frage zusätzliche Details hinzu. – triwo