伙计们,我尝试将其与prestashop函数ConvertPrice(在Tools类中)上的覆盖联系起来:
<span>750</span>,00€
在我的覆盖中使用此代码:
/**
* Return price converted
*
* @param float $price Product price
* @param object $currency Current currency object
* @param boolean $to_currency convert to currency or from currency to 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;
return implode(".", $price);
}