| @@ -271,22 +271,26 @@ | ||
| 271 | 271 | * @return string Formatted amount |
| 272 | 272 | */ |
| 273 | 273 | public static function format(float $amount, string $code = 'USD', bool $showCode = false): string |
| 274 | 274 | { |
| 275 | - $code = strtoupper($code); | |
| 276 | - $currency = self::CURRENCIES[$code] ?? null; | |
| 277 | - | |
| 278 | - if (!$currency) { | |
| 279 | - return number_format($amount, 2) . ' ' . $code; | |
| 275 | + if (function_exists('yatra_format_price')) { | |
| 276 | + $result = yatra_format_price($amount, $code, false); | |
| 277 | + } else { | |
| 278 | + $code = strtoupper($code); | |
| 279 | + $currency = self::CURRENCIES[$code] ?? null; | |
| 280 | + | |
| 281 | + if (!$currency) { | |
| 282 | + return number_format($amount, 2) . ' ' . $code; | |
| 283 | + } | |
| 284 | + | |
| 285 | + $formatted = number_format($amount, $currency['decimal_digits']); | |
| 286 | + $result = $currency['symbol'] . $formatted; | |
| 280 | 287 | } |
| 281 | - | |
| 282 | - $formatted = number_format($amount, $currency['decimal_digits']); | |
| 283 | - $result = $currency['symbol'] . $formatted; | |
| 284 | - | |
| 288 | + | |
| 285 | 289 | if ($showCode) { |
| 286 | - $result .= ' ' . $code; | |
| 290 | + $result .= ' ' . strtoupper($code); | |
| 287 | 291 | } |
| 288 | - | |
| 292 | + | |
| 289 | 293 | return $result; |
| 290 | 294 | } |
| 291 | 295 | |
| 292 | 296 | /** |