15 if (empty($languageId))
17 $languageId = LANGUAGE_ID;
20 if ($languageId ===
'en' &&
$currency ===
"USD")
22 return "$".number_format($price, 2,
".",
",");
24 if ($languageId ===
'en' &&
$currency ===
"EUR")
26 return number_format($price, 2,
".",
",").
" €";
28 if ($languageId ===
'de' &&
$currency ===
"EUR")
30 return number_format($price, 2,
",",
".").
" €";
32 if ($languageId ===
'la' &&
$currency ===
"USD")
34 return "$".number_format($price, 2,
".",
",");
36 if ($languageId ===
'br' &&
$currency ===
"BRL")
38 return "R$".number_format($price, 2,
",",
".");
40 if ($languageId ===
'fr' &&
$currency ===
"EUR")
42 return number_format($price, 2,
".",
",").
" €";
44 if ($languageId ===
'it' &&
$currency ===
"EUR")
46 return number_format($price, 2,
",",
".").
" €";
48 if ($languageId ===
'pl' &&
$currency ===
"PLN")
50 return number_format($price, 2,
",",
" ").
" ¤";
52 if ($languageId ===
'tr' &&
$currency ===
"TRY")
54 return number_format($price, 2,
",",
".").
"₺";
56 if ($languageId ===
'sc' &&
$currency ===
"CNY")
58 return "¥".number_format($price, 2,
".",
"");
60 if ($languageId ===
'tc' &&
$currency ===
"TWD")
62 return "NT$;".number_format($price, 2,
".",
",");
64 if ($languageId ===
'ja' &&
$currency ===
"JPY")
66 return number_format($price, 2,
"",
",").
"¥";
68 if ($languageId ===
'vn' &&
$currency ===
"VND")
70 return number_format($price, 2,
",",
".").
" ₫";
72 if ($languageId ===
'id' &&
$currency ===
"IDR")
74 return "Rs. ".number_format($price, 2,
",",
".");
76 if ($languageId ===
'ms' &&
$currency ===
"MYR")
78 return "RM ".number_format($price, 2,
".",
",");
80 if ($languageId ===
'th' &&
$currency ===
"THB")
82 return "฿ ".number_format($price, 2,
".",
",");
84 if ($languageId ===
'en' &&
$currency ===
"IDR")
86 return "Rs. ".number_format($price, 2,
".",
",");
88 if ($languageId ===
'hi' &&
$currency ===
"IDR")
90 return "Rs. ".number_format($price, 2,
".",
",");
92 if ($languageId ===
'en' &&
$currency ===
"GBP")
94 return "£".number_format($price, 2,
".",
",");
96 if ($languageId ===
'la' &&
$currency ===
"MXN")
98 return "$".number_format($price, 2,
",",
".");
100 if ($languageId ===
'la' &&
$currency ===
"COP")
102 return "$".number_format($price, 2,
",",
".");
105 return "$".number_format($price, 2,
",",
".");
112 if (Loader::includeModule(
'currency') && Loader::includeModule(
'bitrix24'))
114 $currentAreaConfig = \CBitrix24::getCurrentAreaConfig();
115 $currentAreaConfig[
'CURRENCY'] =
$currency;
117 $langSetting = \CCurrencyLang::GetByID($currentAreaConfig[
'CURRENCY'], $currentAreaConfig[
"LANGUAGE_ID"]);
121 isset($formatSetting[
"DECIMALS"])
122 && isset($formatSetting[
"DECIMAL_SEPARATOR"])
123 && isset($formatSetting[
"THOUSANDS_SEPARATOR"])
124 && isset($formatSetting[
"FORMAT_STRING"])
127 $formatSetting[
"THOUSANDS_SEP"] = $formatSetting[
"THOUSANDS_SEPARATOR"];
128 $formatSetting[
"DEC_POINT"] = $formatSetting[
"DECIMAL_SEPARATOR"];
131 return \CCurrencyLang::formatValue($price, $formatSetting);
134 isset($langSetting[
"DECIMALS"])
135 && isset($langSetting[
"DEC_POINT"])
136 && isset($langSetting[
"THOUSANDS_SEP"])
137 && isset($langSetting[
"FORMAT_STRING"])
141 return \CCurrencyLang::formatValue($price, $langSetting);
153 $apiCurrencyFormat = Option::get(
'bitrix24',
'currency_patterns_from_api',
'');
155 if ($apiCurrencyFormat !==
'')
157 $resultOption = Json::decode($apiCurrencyFormat);
159 isset($resultOption[
'time'])
160 && isset($resultOption[
'currencyFormat'])
161 && (((
int)$resultOption[
'time'] + 60*60) > time())
164 return $resultOption[
'currencyFormat'];
169 if (isset($langSetting[
'ID']) && isset($langSetting[
'LANGUAGE_ID']) && isset($langSetting[
'CURRENCY']))
171 $locationAreaId = $langSetting[
'ID'];
172 $languageId = $langSetting[
'LANGUAGE_ID'];
173 $currencyCode = $langSetting[
'CURRENCY'];
176 .
'/b24/catalog/get.php?currencyCode=' . $currencyCode .
'&productType=CLOUD'
177 .
'&locationAreaId=' . $locationAreaId .
'&languageId=' . $languageId .
'&requestData=formatting|patterns'
180 $resultRequest = $httpClient->get(
$url);
183 if ($httpClient->getStatus() === 200)
187 $resultDecode = Json::decode($resultRequest);
194 !empty($resultDecode[
"result"][
"formatting"])
195 && is_array($resultDecode[
"result"][
"formatting"])
198 $result = $resultDecode[
"result"][
"formatting"][
"separators"];
199 $result[
'FORMAT_STRING'] = $resultDecode[
"result"][
"patterns"][
"price"][
'per_period'];
200 $result[
'FORMAT_STRING'] = str_replace(
'#PRICE#',
'#',
$result[
'FORMAT_STRING']);
201 $resultToOption = [
'time' => time(),
'currencyFormat' =>
$result];
202 Option::set(
'bitrix24',
'currency_patterns_from_api', JSON::encode($resultToOption));