bazar
bazar copied to clipboard
Price formatting problem
- Bazar Version: last
- Laravel Version: 8.2
- PHP Version: 7.4
Description:
You have a function in src/Casts/Price.php, this function format price and give from config ex 'eur' => 'EUR' or i have 'ron' => 'Lei'
But give me RON not Lei string
public function format(?string $key = null): ?string
{
$currency = $key ? explode('.', $key, 2)[0] : Bazar::getCurrency();
$price = Arr::get(
$this->toArray(), $key ?: "{$currency}.default"
);
return $price ? Str::currency($price, $currency) : null;
}
So need to fix with this
public function format(?string $key = null): ?string
{
$currency = $key ? explode('.', $key, 2)[0] : Bazar::getCurrency();
//--
$price = Arr::get(
$this->toArray(), $key ?: "{$currency}.default"
);
//--
return $price ? Str::currency($price, array_search($currency, Bazar::getCurrencies())) : null;
}