Merge pull request #2823 from rahulcs0082/development

Development
This commit is contained in:
Jitendra Singh 2020-04-03 13:42:57 +05:30 committed by GitHub
commit 6ee462ac01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 29 deletions

View File

@ -471,40 +471,20 @@ class Core
return $formatter->getSymbol(\NumberFormatter::CURRENCY_SYMBOL);
}
/**
* Format and convert price with currency symbol
*
* @param float $price
* @param string $currencyCode
* @return string
*/
/**
* Format and convert price with currency symbol
*
* @param float $price
* @return string
*/
public function formatPrice($price, $currencyCode)
{
$code = $this->getCurrentCurrency()->code;
if (is_null($price)) {
if (is_null($price))
$price = 0;
} else {
if ($code != $currencyCode) {
$price = $this->convertPrice($price, $code, $currencyCode);
}
}
$formater = new \NumberFormatter(app()->getLocale(), \NumberFormatter::CURRENCY);
$formatter = new \NumberFormatter( app()->getLocale(), \NumberFormatter::CURRENCY );
$symbol = $this->getCurrentCurrency()->symbol;
if ($symbol) {
if ($this->currencySymbol($currencyCode) == $symbol) {
return $formater->formatCurrency($price, $currencyCode);
} else {
$formater->setSymbol(\NumberFormatter::CURRENCY_SYMBOL, $symbol);
return $formater->format($price); // $this->convertPrice($price, $code)
}
} else {
return $formater->formatCurrency($price, $currencyCode);
}
return $formatter->formatCurrency($price, $currencyCode);
}
/**