Yes, Many times this issue is a big problem. I found below file is responsible for this issue.
vendor/magento/module-directory/Model/Currency.php
Solution: https://github.com/magento/magento2/pull/33966/commits/82c1a4d1137f747b9551e7d4d87106bf2c726b9e
You need to update your core Currency.php file. You can not overwrite this core file in your custom module. I tried but it's not working. So I created a custom patch for it.
created custom patch click here: https://magento.stackexchange.com/a/368552/82670
Latest Magento version [2.4.6.p2] Custom Patch for fix this issue
--- a/vendor/magento/module-directory/Model/Currency.php 2023-09-20 10:44:14.635173580 +0200
+++ b/vendor/magento/module-directory/Model/Currency.php 2023-09-20 10:41:29.819340923 +0200
@@ -14,6 +14,7 @@
use Magento\Framework\Locale\ResolverInterface as LocalResolverInterface;
use Magento\Framework\NumberFormatterFactory;
use Magento\Framework\Serialize\Serializer\Json;
+use Magento\Framework\NumberFormatter;
/**
@@ -85,7 +86,7 @@
private $numberFormatterFactory;
/**
@@ -444,9 +445,9 @@
* Get NumberFormatter object from cache.
*
* @param array $options
- private function getNumberFormatter(array $options): \Magento\Framework\NumberFormatter
- private function getNumberFormatter(array $options): NumberFormatter
{
$locale = $this->localeResolver->getLocale() . ($this->getCode() ? '@currency=' . $this->getCode() : '');
$key = 'currency_' . hash('sha256', $locale . $this->serializer->serialize($options));
@@ -479,6 +480,7 @@
if (array_key_exists(LocaleCurrency::CURRENCY_OPTION_DISPLAY, $options)
&& $options[LocaleCurrency::CURRENCY_OPTION_DISPLAY] === \Magento\Framework\Currency::NO_SYMBOL) {
$this->numberFormatter->setSymbol(\NumberFormatter::CURRENCY_SYMBOL, '');
$this->numberFormatter->setPattern(str_replace('¤', '', $this->numberFormatter->getPattern()));
}
if (array_key_exists('precision', $options)) {
$this->numberFormatter->setAttribute(\NumberFormatter::FRACTION_DIGITS, $options['precision']);
@@ -503,7 +505,7 @@
public function getOutputFormat()
{
$formatted = $this->formatTxt(0);
$number = str_replace($this->getCurrencySymbol(), '', $formatted);
return $formatted !== null ? str_replace($this->trimUnicodeDirectionMark($number), '%s', $formatted) : '';
}
@@ -581,9 +583,9 @@
* This method removes LRM and RLM marks from string
*
* @param string $string
- private function trimUnicodeDirectionMark($string)
- private function trimUnicodeDirectionMark(string $string): string
{
if (preg_match('/^(\x{200E}|\x{200F})/u', $string, $match)) {
$string = preg_replace('/^' . $match[1] . '/u', '', $string);