public static formatMoney ( $number, $locale = null, $internationalFormat = null, $format = true ) : string | ||
$number | ||
$locale | ||
$internationalFormat | ||
$format | ||
return | string |
public static function formatMoney($number, $locale = null, $internationalFormat = null, $format = true)
{
$number = number_format($number, 2, '.', '');
if ($format) {
setlocale(LC_MONETARY, null);
setlocale(LC_MONETARY, empty($locale) ? config('laracart.locale', 'en_US.UTF-8') : $locale);
if (empty($internationalFormat) === true) {
$internationalFormat = config('laracart.international_format', false);
}
$number = money_format($internationalFormat ? '%i' : '%n', $number);
}
return $number;
}
/** * Gets the formatted price * * @param bool|true $format * * @return string */ public function price($format = true) { $price = $this->price; if (isset($this->items)) { foreach ($this->items as $item) { $price += $item->price(false); } } return LaraCart::formatMoney($price, $this->locale, $this->internationalFormat, $format); }