у меня возникла также и другая проблемка, раньше были названия городов и регионов имели следующий вид: $arEMSCityList['Абакан'] = 'city--abakan';
а теперь
$arEMSCityList['АБАКАН'] = 'city--abakan'; - в случае если удалить папочку ems, чтоб список городов записался заново
поэтому для решения можно добавить
Код |
---|
function __GetLocation($location)
{
$arLocation = CSaleLocation::GetByID($location);
$arLocation["IS_RUSSIAN"] = CDeliveryEMS::__IsRussian($arLocation) ? "Y" : "N";
if ($arLocation["IS_RUSSIAN"] == 'Y')
{
static $arEMSCityList;
if (!is_array($arEMSCityList))
{
if (file_exists(dirname(__FILE__).'/ems/city.php'))
require_once(dirname(__FILE__).'/ems/city.php');
}
/// >>>>>>>>>>>>>
$arLocation['CITY_NAME_ORIG'] = ToUpper($arLocation['CITY_NAME_ORIG']);
$arLocation['CITY_SHORT_NAME'] = ToUpper($arLocation['CITY_SHORT_NAME']);
$arLocation['CITY_NAME_LANG'] = ToUpper($arLocation['CITY_NAME_LANG']);
$arLocation['CITY_NAME'] = ToUpper($arLocation['CITY_NAME']);
// <<<<<<<<<<<<<<<
if (is_array($arEMSCityList))
{
$arLocation['EMS_ID'] =
$arEMSCityList[$arLocation['CITY_NAME_ORIG']] ? $arEMSCityList[$arLocation['CITY_NAME_ORIG']] : (
$arEMSCityList[$arLocation['CITY_SHORT_NAME']] ? $arEMSCityList[$arLocation['CITY_SHORT_NAME']] : (
$arEMSCityList[$arLocation['CITY_NAME_LANG']] ? $arEMSCityList[$arLocation['CITY_NAME_LANG']] : (
$arEMSCityList[$arLocation['CITY_NAME']] ? $arEMSCityList[$arLocation['CITY_NAME']] : ''
)
)
);
$arLocation['EMS_TYPE'] = 'city';
}
else
{
$arLocation['EMS_CITIES_NOT_LOADED'] = true;
}
............................ |
Если кому то необходимо добавить регионы, я сделал так:
Код |
---|
function Calculate($profile, $arConfig, $arOrder, $STEP, $TEMP = false)
{
//echo '<pre style="text-align: left;">'; print_r($arOrder); print_r($arConfig); echo '</pre>';
if ($STEP >= 4)
return array(
"RESULT" => "ERROR",
"TEXT" => GetMessage('SALE_DH_EMS_ERROR_CONNECT'),
);
if ($arOrder["WEIGHT"] <= 0) $arOrder["WEIGHT"] = 1;
$arLocationTo = CDeliveryEMS::__GetLocation($arOrder["LOCATION_TO"]);
if ($arLocationTo['IS_RUSSIAN'] == 'Y')
$arLocationFrom = CDeliveryEMS::__GetLocation($arOrder["LOCATION_FROM"]);
if (isset($arLocationTo['EMS_CITIES_NOT_LOADED']))
{
// get cities and proceed to next step
$data = CDeliveryEMS::__EMSQuery('ems.get.locations', array('type' => 'cities', 'plain' => 'true'));
if (!is_array($data) || $data['rsp']['stat'] != 'ok' || !is_array($data['rsp']['locations']))
{
return array(
"RESULT" => "ERROR",
"TEXT" => GetMessage('SALE_DH_EMS_ERROR_CONNECT'),
);
}
$arCitiesList = array();
foreach ($data['rsp']['locations'] as $arLocation)
{
$arCitiesList[$arLocation['name']] = $arLocation['value'];
}
/** Запишем также регионы
* *********************************** */
$data = CDeliveryEMS::__EMSQuery('ems.get.locations', array('type' => 'regions', 'plain' => 'true'));
if (!is_array($data) || $data['rsp']['stat'] != 'ok' || !is_array($data['rsp']['locations']))
{
return array(
"RESULT" => "ERROR",
"TEXT" => GetMessage('SALE_DH_EMS_ERROR_CONNECT'),
);
}
foreach ($data['rsp']['locations'] as $arLocation)
{
$arCitiesList[$arLocation['name']] = $arLocation['value'];
}
CheckDirPath(dirname(__FILE__)."/ems/");
if ($fp = fopen(dirname(__FILE__)."/ems/city.php", "w"))
{
fwrite($fp, '<'."?\r\n");
fwrite($fp, '$'."arEMSCityList = array();\r\n");
foreach ($arCitiesList as $key => $value)
{
fwrite($fp, '$'."arEMSCityList['".addslashes($key)."'] = '".htmlspecialchars($value, ENT_QUOTES)."';\r\n");
}
fwrite($fp, '?'.'>');
fclose($fp);
}
// вернем результат
return array(
"RESULT" => "NEXT_STEP",
"TEXT" => GetMessage('SALE_DH_EMS_CORRECT_CITIES'),
);
}
if (isset( X
|