@@ -28,11 +28,11 @@ class Currency extends \Magento\Framework\Model\AbstractModel
2828 /**
2929 * CONFIG path constants
3030 */
31- const XML_PATH_CURRENCY_ALLOW = 'currency/options/allow ' ;
31+ public const XML_PATH_CURRENCY_ALLOW = 'currency/options/allow ' ;
3232
33- const XML_PATH_CURRENCY_DEFAULT = 'currency/options/default ' ;
33+ public const XML_PATH_CURRENCY_DEFAULT = 'currency/options/default ' ;
3434
35- const XML_PATH_CURRENCY_BASE = 'currency/options/base ' ;
35+ public const XML_PATH_CURRENCY_BASE = 'currency/options/base ' ;
3636
3737 /**
3838 * @var Filter
@@ -439,7 +439,13 @@ private function formatCurrency(string $price, array $options): string
439439
440440 if ((array_key_exists (LocaleCurrency::CURRENCY_OPTION_DISPLAY , $ options )
441441 && $ 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+ }
443449 }
444450
445451 return preg_replace ('/^\s+|\s+$/u ' , '' , $ formattedCurrency );
@@ -597,4 +603,15 @@ private function trimUnicodeDirectionMark($string)
597603 }
598604 return $ string ;
599605 }
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+ }
600617}
0 commit comments