spals Posted August 22, 2015 Share Posted August 22, 2015 Добрый вечер. В product-list.tpl есть вывод цены {convertPrice price=$product.price} Как вывести по отдельности, цену и знак валюты? Всего то и требуется что бы знак валюты был на следующей строке, или поставить br перед РУБ. Кто подскажет как )) Link to comment Share on other sites More sharing options...
Sashok Posted August 30, 2015 Share Posted August 30, 2015 перекрыть можно функцию формирования написания цены: /override/classes/Tools.php здесь я, например, везде по сайту добавил к цене слово ОТ, т.е. было "100 грн." стало "от 100 грн." там же можно и <br/> втулить куда надо, только зависит от настроек самой валюты и т.д. <?php class Tools extends ToolsCore { public static function displayPrice($price, $currency = null, $no_utf8 = false, Context $context = null) { if (!is_numeric($price)) return $price; if (!$context) $context = Context::getContext(); if ($currency === null) $currency = $context->currency; // if you modified this function, don't forget to modify the Javascript function formatCurrency (in tools.js) elseif (is_int($currency)) $currency = Currency::getCurrencyInstance((int)$currency); if (is_array($currency)) { $c_char = $currency['sign']; $c_format = $currency['format']; $c_decimals = (int)$currency['decimals'] * _PS_PRICE_DISPLAY_PRECISION_; $c_blank = $currency['blank']; } elseif (is_object($currency)) { $c_char = $currency->sign; $c_format = $currency->format; $c_decimals = (int)$currency->decimals * _PS_PRICE_DISPLAY_PRECISION_; $c_blank = $currency->blank; } else return false; $blank = ($c_blank ? ' ' : ''); $ret = 0; if (($is_negative = ($price < 0))) $price *= -1; $price = Tools::ps_round($price, $c_decimals); /* * If the language is RTL and the selected currency format contains spaces as thousands separator * then the number will be printed in reverse since the space is interpreted as separating words. * To avoid this we replace the currency format containing a space with the one containing a comma (,) as thousand * separator when the language is RTL. * * TODO: This is not ideal, a currency format should probably be tied to a language, not to a currency. */ if (($c_format == 2) && ($context->language->is_rtl == 1)) $c_format = 4; switch ($c_format) { /* X 0,000.00 */ case 1: $ret = $c_char.$blank.number_format($price, $c_decimals, '.', ','); break; /* 0 000,00 X*/ case 2: $ret = number_format($price, $c_decimals, ',', ' ').$blank.$c_char; break; /* X 0.000,00 */ case 3: $ret = $c_char.$blank.number_format($price, $c_decimals, ',', '.'); break; /* 0,000.00 X */ case 4: $ret = number_format($price, $c_decimals, '.', ',').$blank.$c_char; break; /* X 0'000.00 Added for the switzerland currency */ case 5: $ret = number_format($price, $c_decimals, '.', "'").$blank.$c_char; break; } if ($is_negative) $ret = '-'.$ret; if ($no_utf8) return str_replace('€', chr(128), $ret); //webpc $ret='от '.$ret; return $ret; } } успехов! 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