enagen Posted July 27, 2012 Share Posted July 27, 2012 Does anyone know how to change the size of decimal in PS 1.4 ?? To display price like this: 1000 This solution from previous version is not available now http://www.prestasho...aller-decimals/ Any ideas? Thanks! Link to comment Share on other sites More sharing options...
Médéric Posted July 27, 2012 Share Posted July 27, 2012 (edited) hello, EDIT: !!!! don't work with the AJAX cart !!!! The code of the other post was almost good. It will be for you : line 392 classes/Tools.php - Prestashop 1.4.8.2 ! public static function displayPrice($price, $currency = NULL, $no_utf8 = false) { if ($currency === NULL) $currency = Currency::getCurrent(); /* if you modified this function, don't forget to modify the Javascript function formatCurrency (in tools.js) */ if (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 (($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; /* 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; } if ($isNegative) $ret = '-'.$ret; /* decimal size */ if ($no_utf8) return str_replace('€', chr(128), $ret); $des_sep = "."; if ($c_format == 2 || $c_format == 4) $des_sep = ","; if (strstr($ret, $des_sep) !== false) { $tmp_ret = explode($des_sep, $ret); $tmp_dec = explode(" ",$tmp_ret[1]); $ret = $tmp_ret[0]."<sup style='font-size:10px'>".$tmp_dec[0]."</sup>".(sizeof($tmp_dec) == 2?" ".$tmp_dec[1]:""); } return $ret; } You need to override the "displayPrice" function with this one, and : - change the "sup" for a span to stylize with a CSS. - check for the currency symbol. bye Edited July 27, 2012 by Médéric (see edit history) Link to comment Share on other sites More sharing options...
enagen Posted July 27, 2012 Author Share Posted July 27, 2012 (edited) Thnks for response! So you said to substitute this code ? if i do, the page doesn't load. if ($no_utf8) return str_replace('€', chr(128), $ret); return $ret; } public static function displayPriceSmarty($params, &$smarty) { if (array_key_exists('currency', $params)) { $currency = Currency::getCurrencyInstance((int)($params['currency'])); if (Validate::isLoadedObject($currency)) return self::displayPrice($params['price'], $currency, false); } return self::displayPrice($params['price']); } Edited July 27, 2012 by enagen (see edit history) Link to comment Share on other sites More sharing options...
Médéric Posted July 27, 2012 Share Posted July 27, 2012 So you said to substitute this code ? if i do, the page doesn't load. No you have to override the files Tools.php more information on this page : http://doc.prestasho...roller+Override But it's a partial solution !! It's don't work with the ajax cart who don't interpret the html in this case (module blockcart). And the product page has it's own function for the price (product.tpl, tools.js). It can be hard if you are not used to modify this files. Link to comment Share on other sites More sharing options...
enagen Posted July 28, 2012 Author Share Posted July 28, 2012 Thank u so much Médéric! I'll try to apply this information! Regards! Link to comment Share on other sites More sharing options...
dj-valerka Posted June 10, 2015 Share Posted June 10, 2015 How to change style of decimal in PS 1.6 ? 1 Link to comment Share on other sites More sharing options...
electrostuff_de Posted April 26, 2017 Share Posted April 26, 2017 How to change style of decimal in PS 1.6 ? I also would love to know that... Link to comment Share on other sites More sharing options...
Recommended Posts