@@ -28,11 +28,11 @@ class Currency extends \Magento\Framework\Model\AbstractModel
28
28
/**
29
29
* CONFIG path constants
30
30
*/
31
- const XML_PATH_CURRENCY_ALLOW = 'currency/options/allow ' ;
31
+ public const XML_PATH_CURRENCY_ALLOW = 'currency/options/allow ' ;
32
32
33
- const XML_PATH_CURRENCY_DEFAULT = 'currency/options/default ' ;
33
+ public const XML_PATH_CURRENCY_DEFAULT = 'currency/options/default ' ;
34
34
35
- const XML_PATH_CURRENCY_BASE = 'currency/options/base ' ;
35
+ public const XML_PATH_CURRENCY_BASE = 'currency/options/base ' ;
36
36
37
37
/**
38
38
* @var Filter
@@ -439,7 +439,13 @@ private function formatCurrency(string $price, array $options): string
439
439
440
440
if ((array_key_exists (LocaleCurrency::CURRENCY_OPTION_DISPLAY , $ options )
441
441
&& $ options [LocaleCurrency::CURRENCY_OPTION_DISPLAY ] === \Magento \Framework \Currency::NO_SYMBOL )) {
442
- $ formattedCurrency = preg_replace (['/[^0-9.,۰٫]+/ ' , '/ / ' ], '' , $ formattedCurrency );
442
+ if ($ this ->isArabicSymbols ($ formattedCurrency )) {
443
+ /* Workaround. We need to provide Arabic symbols range and Unicode modifier into expression
444
+ to bypass issue when preg_replace with Arabic symbol return corrupted result */
445
+ $ formattedCurrency = preg_replace (['/[^0-9\x{0600}-\x{06FF}.,۰٫]+/u ' , '/ / ' ], '' , $ formattedCurrency );
446
+ } else {
447
+ $ formattedCurrency = preg_replace (['/[^0-9.,۰٫]+/ ' , '/ / ' ], '' , $ formattedCurrency );
448
+ }
443
449
}
444
450
445
451
return preg_replace ('/^\s+|\s+$/u ' , '' , $ formattedCurrency );
@@ -597,4 +603,15 @@ private function trimUnicodeDirectionMark($string)
597
603
}
598
604
return $ string ;
599
605
}
606
+
607
+ /**
608
+ * Checks if given string is of Arabic symbols
609
+ *
610
+ * @param string $string
611
+ * @return bool
612
+ */
613
+ private function isArabicSymbols (string $ string ): bool
614
+ {
615
+ return preg_match ('/[\p{Arabic}]/u ' , $ string ) > 0 ;
616
+ }
600
617
}
0 commit comments