} else { $cachedData['ZONE_IDS'] = SalesZone::getSelectedIds($arParams["SITE_ID"]); $cachedData['DEFAULT_LOCS'] = array(); $res = CSaleLocation::GetList(array("SORT" => "ASC", "COUNTRY_NAME_LANG" => "ASC", "CITY_NAME_LANG" => "ASC"), array("LOC_DEFAULT" => "Y", "LID" => LANGUAGE_ID), false, false, array("*")); while ($item = $res->fetch()) { $cachedData['DEFAULT_LOCS'][] = $item; } } SalesZone::setSelectedIds($arParams["SITE_ID"], $cachedData['ZONE_IDS']); ###################################################### ###################################################### ###################################################### // take into account sales zone // 1. check if ONLY a single city is connected to sale zone $arResult["SINGLE_CITY"] = "N"; $citiesIds = SalesZone::getCitiesIds($arParams["SITE_ID"]); if (count($citiesIds) == 1 && strlen($citiesIds[0]) > 0) { $rsLocationsList = CSaleLocation::GetList(array(), array("CITY_ID" => $citiesIds[0]), false, false, array("ID")); if ($arLoc = $rsLocationsList->GetNext()) { $arParams["LOCATION_VALUE"] = $arLoc["ID"]; $arResult["SINGLE_CITY"] = "Y"; } } // 2. check location is connected to a sale zone if (!SalesZone::checkLocationId($arParams["LOCATION_VALUE"], $arParams["SITE_ID"])) { $arParams["LOCATION_VALUE"] = 0; } if ($arParams["LOCATION_VALUE"] > 0) { if ($arLocation = CSaleLocation::GetByID($arParams["LOCATION_VALUE"])) { $arParams["COUNTRY"] = $arLocation["COUNTRY_ID"]; $arParams["REGION"] = $arLocation["REGION_ID"];
public static function convertSalesZones() { $siteList = \CSaleLocation::getSites(); $siteList[] = ''; // 'empty site' too foreach ($siteList as $siteId) { $countries = Sale\SalesZone::getCountriesIds($siteId); $regions = Sale\SalesZone::getRegionsIds($siteId); $cities = Sale\SalesZone::getCitiesIds($siteId); if (empty($countries) && empty($regions) && empty($cities)) { continue; } Sale\SalesZone::saveSelectedTypes(array('COUNTRY' => $countries, 'REGION' => $regions, 'CITY' => $cities), $siteId); } }
<?php if ($lpEnabled) { ?> <?php /*<a href="<?=\Bitrix\Sale\Location\Admin\SiteLocationHelper::getListUrl();?>"><?=GetMessage('SMO_LOCATION_SALES_ZONE_SELECT')?></a>*/ ?> <?php } else { ?> <?php $sales_zone_countries = \Bitrix\Sale\SalesZone::getCountriesIds($siteList[$i]["ID"]); $sales_zone_regions = \Bitrix\Sale\SalesZone::getRegionsIds($siteList[$i]["ID"]); $sales_zone_cities = \Bitrix\Sale\SalesZone::getCitiesIds($siteList[$i]["ID"]); ?> <table><tr> <th><?php echo GetMessage("SMO_LOCATION_COUNTRIES"); ?> </th> <th><?php echo GetMessage("SMO_LOCATION_REGIONS"); ?> </th> <th><?php echo GetMessage("SMO_LOCATION_CITIES"); ?> </th>
} ?> </select><input type="hidden" name="ADDRESS_current_site" id="ADDRESS_current_site" value="<?php echo $siteList[0]["ID"]; ?> " /></td> </tr> <tr> <td colspan="2" valign="top"> <?php for ($i = 0; $i < $siteCount; $i++) { $location_zip = COption::GetOptionString('sale', 'location_zip', '', $siteList[$i]["ID"]); $location = intval(COption::GetOptionString('sale', 'location', '', $siteList[$i]["ID"])); $sales_zone_countries = SalesZone::getCountriesIds($siteList[$i]["ID"]); $sales_zone_regions = SalesZone::getRegionsIds($siteList[$i]["ID"]); $sales_zone_cities = SalesZone::getCitiesIds($siteList[$i]["ID"]); if ($location_zip == 0) { $location_zip = ''; } ?> <div id="par_ADDRESS_<?php echo $siteList[$i]["ID"]; ?> " style="display: <?php echo $i == 0 ? "inline" : "none"; ?> "> <table cellpadding="0" cellspacing="2" border="0" width="60%" align="center"> <tr class="heading"> <td align="center" colspan="2"><?php echo GetMessage("SMO_PAR_SITE_ADRES");