Skip to content

Commit fc2d417

Browse files
committed
ACP2E-1012: No space between a custom currency symbol and a price
1 parent d7cb544 commit fc2d417

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,11 @@ class Currencysymbol
2727
protected $_symbolsData = [];
2828

2929
/**
30-
* Store id
31-
*
3230
* @var string|null
3331
*/
3432
protected $_storeId;
3533

3634
/**
37-
* Website id
38-
*
3935
* @var string|null
4036
*/
4137
protected $_websiteId;
@@ -55,19 +51,19 @@ class Currencysymbol
5551
/**
5652
* Config path to custom currency symbol value
5753
*/
58-
const XML_PATH_CUSTOM_CURRENCY_SYMBOL = 'currency/options/customsymbol';
54+
public const XML_PATH_CUSTOM_CURRENCY_SYMBOL = 'currency/options/customsymbol';
5955

60-
const XML_PATH_ALLOWED_CURRENCIES = \Magento\Directory\Model\Currency::XML_PATH_CURRENCY_ALLOW;
56+
public const XML_PATH_ALLOWED_CURRENCIES = \Magento\Directory\Model\Currency::XML_PATH_CURRENCY_ALLOW;
6157

6258
/*
6359
* Separator used in config in allowed currencies list
6460
*/
65-
const ALLOWED_CURRENCIES_CONFIG_SEPARATOR = ',';
61+
public const ALLOWED_CURRENCIES_CONFIG_SEPARATOR = ',';
6662

6763
/**
6864
* Config currency section
6965
*/
70-
const CONFIG_SECTION = 'currency';
66+
public const CONFIG_SECTION = 'currency';
7167

7268
/**
7369
* Core event manager proxy

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
namespace Magento\Directory\Model;
88

9+
use Magento\Directory\Model\Currency\Filter;
910
use Magento\Framework\App\ObjectManager;
1011
use Magento\Framework\Exception\InputException;
11-
use Magento\Directory\Model\Currency\Filter;
12+
use Magento\Framework\Exception\LocalizedException;
1213
use Magento\Framework\Locale\Currency as LocaleCurrency;
1314
use Magento\Framework\Locale\ResolverInterface as LocalResolverInterface;
1415
use Magento\Framework\NumberFormatterFactory;
1516
use Magento\Framework\Serialize\Serializer\Json;
16-
use Magento\Framework\Exception\LocalizedException;
1717

1818
/**
1919
* Currency model
@@ -432,6 +432,11 @@ 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);
439+
}
435440
if ((array_key_exists(LocaleCurrency::CURRENCY_OPTION_DISPLAY, $options)
436441
&& $options[LocaleCurrency::CURRENCY_OPTION_DISPLAY] === \Magento\Framework\Currency::NO_SYMBOL)) {
437442
$formattedCurrency = str_replace(' ', '', $formattedCurrency);
@@ -586,7 +591,7 @@ public function saveRates($rates)
586591
private function trimUnicodeDirectionMark($string)
587592
{
588593
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);
590595
}
591596
return $string;
592597
}

0 commit comments

Comments
 (0)