Skip to content

Commit 828d086

Browse files
committed
ACP2E-1012: No space between a custom currency symbol and a price
1 parent 4f19480 commit 828d086

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

app/code/Magento/CurrencySymbol/Model/System/Currencysymbol.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,7 @@ public function getCurrencySymbol($code)
239239
{
240240
$customSymbols = $this->_unserializeStoreConfig(self::XML_PATH_CUSTOM_CURRENCY_SYMBOL);
241241
if (array_key_exists($code, $customSymbols)) {
242-
// remove non-breaking space from custom currency symbol and allow custom NBSP in currency symbol
243-
return preg_replace('/( |&nbsp|\xc2\xa0)*/iu', '', $customSymbols[$code]);
242+
return $customSymbols[$code];
244243
}
245244

246245
return false;

app/code/Magento/Directory/Model/Currency.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -432,11 +432,16 @@ private function formatCurrency(string $price, array $options): string
432432
$this->getCode() ?? $this->numberFormatter->getTextAttribute(\NumberFormatter::CURRENCY_CODE)
433433
);
434434

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);
435+
if (array_key_exists(LocaleCurrency::CURRENCY_OPTION_SYMBOL, $options)) {
436+
// remove non-breaking space from custom currency code and allow custom NBSP in currency code
437+
$formattedCurrency = preg_replace('/( |&nbsp|\xc2\xa0)*/iu', '', $formattedCurrency);
438+
439+
if (!array_key_exists(LocaleCurrency::CURRENCY_OPTION_DISPLAY, $options)) {
440+
// remove any space from intl supported custom currency symbol in formatted currency
441+
$formattedCurrency = str_replace(' ', '', $formattedCurrency);
442+
}
439443
}
444+
440445
if ((array_key_exists(LocaleCurrency::CURRENCY_OPTION_DISPLAY, $options)
441446
&& $options[LocaleCurrency::CURRENCY_OPTION_DISPLAY] === \Magento\Framework\Currency::NO_SYMBOL)) {
442447
$formattedCurrency = str_replace(' ', '', $formattedCurrency);

0 commit comments

Comments
 (0)