php - ConvertPrice changing -



php - ConvertPrice changing -

i guys seek create link override on prestashop function convertprice (in tools class) :

<span>750</span>,00€

with code in override :

/** * homecoming cost converted * * @param float $price product cost * @param object $currency current currency object * @param boolean $to_currency convert currency or currency default currency */ public static function convertprice($price, $currency = null, $to_currency = true) { if ($currency === null) $currency = currency::getcurrent(); elseif (is_numeric($currency)) $currency = currency::getcurrencyinstance($currency); $c_id = (is_array($currency) ? $currency['id_currency'] : $currency->id); $c_rate = (is_array($currency) ? $currency['conversion_rate'] : $currency->conversion_rate); if ($c_id != (int)(configuration::get('ps_currency_default'))) { if ($to_currency) $price *= $c_rate; else $price /= $c_rate; } $price = explode(".", strval($price)); $temp = '<span>'.$price[0]."</span>"; $price[0] = $temp; homecoming implode(".", $price); }

i founded solution myself, didn't edit right function there right way :

public static function displayprice($price, $currency = null, $no_utf8 = false){ if ($currency === null) $currency = currency::getcurrent(); if (is_int($currency)) $currency = currency::getcurrencyinstance((int)($currency)); $c_char = (is_array($currency) ? $currency['sign'] : $currency->sign); $c_format = (is_array($currency) ? $currency['format'] : $currency->format); $c_decimals = (is_array($currency) ? (int)($currency['decimals']) : (int)($currency->decimals)) * _ps_price_display_precision_; $c_blank = (is_array($currency) ? $currency['blank'] : $currency->blank); $blank = ($c_blank ? ' ' : ''); $ret = 0; if (($isnegative = ($price < 0))) $price *= -1; $price = self::ps_round($price, $c_decimals); switch ($c_format){ /* x 0,000.00 */ case 1: $ret = $c_char.$blank.number_format($price, $c_decimals, '.', ','); break; /* 0000,00 x*/ case 2: $ret = number_format($price, $c_decimals, ',', '').$blank.$c_char; $price = explode(",", strval($ret)); $price[0] = '<span>'.$price[0]."</span>"; $ret = implode(",", $price); 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; } if ($isnegative) $ret = '-'.$ret; if ($no_utf8) homecoming str_replace('€', chr(128), $ret); homecoming $ret; }

in override/classes/tools.php

php prestashop

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -