|
6 | 6 |
|
7 | 7 | namespace Magento\Directory\Model;
|
8 | 8 |
|
| 9 | +use Magento\Directory\Model\Currency\Filter; |
9 | 10 | use Magento\Framework\App\ObjectManager;
|
10 | 11 | use Magento\Framework\Exception\InputException;
|
11 |
| -use Magento\Directory\Model\Currency\Filter; |
| 12 | +use Magento\Framework\Exception\LocalizedException; |
12 | 13 | use Magento\Framework\Locale\Currency as LocaleCurrency;
|
13 | 14 | use Magento\Framework\Locale\ResolverInterface as LocalResolverInterface;
|
14 | 15 | use Magento\Framework\NumberFormatterFactory;
|
15 | 16 | use Magento\Framework\Serialize\Serializer\Json;
|
16 |
| -use Magento\Framework\Exception\LocalizedException; |
17 | 17 |
|
18 | 18 | /**
|
19 | 19 | * Currency model
|
@@ -432,6 +432,11 @@ private function formatCurrency(string $price, array $options): string
|
432 | 432 | $this->getCode() ?? $this->numberFormatter->getTextAttribute(\NumberFormatter::CURRENCY_CODE)
|
433 | 433 | );
|
434 | 434 |
|
| 435 | + if (array_key_exists(LocaleCurrency::CURRENCY_OPTION_SYMBOL, $options) |
| 436 | + && !array_key_exists(LocaleCurrency::CURRENCY_OPTION_DISPLAY, $options)) { |
| 437 | + // remove only one non-breaking space from custom currency symbol to allow custom NBSP in currency symbol |
| 438 | + $formattedCurrency = preg_replace('/ /u', '', $formattedCurrency, 1); |
| 439 | + } |
435 | 440 | if ((array_key_exists(LocaleCurrency::CURRENCY_OPTION_DISPLAY, $options)
|
436 | 441 | && $options[LocaleCurrency::CURRENCY_OPTION_DISPLAY] === \Magento\Framework\Currency::NO_SYMBOL)) {
|
437 | 442 | $formattedCurrency = str_replace(' ', '', $formattedCurrency);
|
@@ -586,7 +591,7 @@ public function saveRates($rates)
|
586 | 591 | private function trimUnicodeDirectionMark($string)
|
587 | 592 | {
|
588 | 593 | if (preg_match('/^(\x{200E}|\x{200F})/u', $string, $match)) {
|
589 |
| - $string = preg_replace('/^'.$match[1].'/u', '', $string); |
| 594 | + $string = preg_replace('/^' . $match[1] . '/u', '', $string); |
590 | 595 | }
|
591 | 596 | return $string;
|
592 | 597 | }
|
|
0 commit comments