public
getPriceFormat
(mixed $price, mixed $negative = 0, mixed $skipCurrencyConverting = 0, mixed $forceCurrency = 0, mixed $skipPrefix = 0, mixed $skipSuffix = 0)
/*
* 1) the price can be negative - for example rounding
* 2) or we can force the negative - e.g. for discount
*/
public function getPriceFormat($price, $negative = 0, $skipCurrencyConverting = 0, $forceCurrency = 0, $skipPrefix = 0, $skipSuffix = 0)
{
$currentCurrency = $this->currency_id;
if ((int) $forceCurrency > 0) {
$this->setCurrency((int) $forceCurrency);
}
if ($price < 0) {
$negative = 1;
}
// If negative is forced by parameter but the price is 0 in real - skip the negative sign
if ($price == 0) {
$negative = 0;
}
if ($price == '') {
$price = 0;
}
if ($skipCurrencyConverting == 0) {
$price *= $this->exchange_rate;
}
// Round after exchange rate
$price = $this->roundPrice($price);
if ($negative) {
$price = abs($price);
}
$price = number_format((double) $price, $this->price_decimals, $this->price_dec_symbol, $this->price_thousands_sep);
switch ($this->price_format) {
case 1:
$price = $price . $this->price_currency_symbol;
break;
case 2:
$price = $this->price_currency_symbol . $price;
break;
case 3:
$price = $this->price_currency_symbol . ' ' . $price;
break;
case 0:
default:
$price = $price . ' ' . $this->price_currency_symbol;
break;
}
$o = '';
if ($negative) {
$o = '- ' . $this->price_prefix . $price . $this->price_suffix;
} else {
$o = $this->price_prefix . $price . $this->price_suffix;
}
if ((int) $forceCurrency > 0) {
$this->setCurrency((int) $currentCurrency);
}
return $o;
}