Jump to content

Decimals - Change Font Size


Recommended Posts

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 by Médéric (see edit history)
Link to comment
Share on other sites

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 by enagen (see edit history)
Link to comment
Share on other sites

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

  • 2 years later...
  • 1 year later...
×
×
  • Create New...