本文整理汇总了PHP中CSaleLocation::DeleteCity方法的典型用法代码示例。如果您正苦于以下问题:PHP CSaleLocation::DeleteCity方法的具体用法?PHP CSaleLocation::DeleteCity怎么用?PHP CSaleLocation::DeleteCity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSaleLocation
的用法示例。
在下文中一共展示了CSaleLocation::DeleteCity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Delete
/**
* <p>Функция удаляет местоположение с кодом ID. Функция так же удаляет город этого местоположения, страну этого местоположения (если она не входит больше ни в одно другое местоположение), а так же связи этого местоположения с группами местоположений и службами доставки. </p>
*
*
*
*
* @param int $ID Код местоположения. </h
*
*
*
* @return bool <p>Функция возвращает <i>true</i> в случае успешного удаления
* местоположения и <i>false</i> - в противном случае.</p> <a name="examples"></a>
*
*
* <h4>Example</h4>
* <pre>
* <?
* if (!CSaleLocation::Delete(12))
* echo "Ошибка удаления местоположения";<br>?>
* </pre>
*
*
* @static
* @link http://dev.1c-bitrix.ru/api_help/sale/classes/csalelocation/csalelocation__delete.008e0aa2.php
* @author Bitrix
*/
public static function Delete($ID)
{
global $DB;
$ID = IntVal($ID);
if (!($arLocRes = CSaleLocation::GetByID($ID, LANGUAGE_ID))) {
return false;
}
foreach (GetModuleEvents("sale", "OnBeforeLocationDelete", true) as $arEvent) {
if (ExecuteModuleEventEx($arEvent, array($ID)) === false) {
return false;
}
}
if (IntVal($arLocRes["CITY_ID"]) > 0) {
CSaleLocation::DeleteCity($arLocRes["CITY_ID"]);
}
$bDelCountry = True;
$db_res = CSaleLocation::GetList(array("SORT" => "ASC"), array("COUNTRY_ID" => $arLocRes["COUNTRY_ID"], "!ID" => $ID), LANGUAGE_ID);
if ($db_res->Fetch()) {
$bDelCountry = false;
}
if ($bDelCountry && IntVal($arLocRes["COUNTRY_ID"]) > 0) {
CSaleLocation::DeleteCountry($arLocRes["COUNTRY_ID"]);
}
$bDelRegion = True;
$db_res = CSaleLocation::GetList(array("SORT" => "ASC"), array("REGION_ID" => $arLocRes["REGION_ID"], "!ID" => $ID), LANGUAGE_ID);
if ($db_res->Fetch()) {
$bDelRegion = false;
}
if ($bDelRegion && IntVal($arLocRes["REGION_ID"]) > 0) {
CSaleLocation::DeleteRegion($arLocRes["REGION_ID"]);
}
$DB->Query("DELETE FROM b_sale_location2location_group WHERE LOCATION_ID = " . $ID . "", true);
$DB->Query("DELETE FROM b_sale_delivery2location WHERE LOCATION_ID = " . $ID . " AND LOCATION_TYPE = 'L'", true);
$DB->Query("DELETE FROM b_sale_location_zip WHERE LOCATION_ID = " . $ID . "", true);
$bDelete = $DB->Query("DELETE FROM b_sale_location WHERE ID = " . $ID . "", true);
foreach (GetModuleEvents("sale", "OnLocationDelete", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($ID));
}
return $bDelete;
}
示例2: Delete
function Delete($ID)
{
global $DB;
$ID = IntVal($ID);
if (!($arLocRes = CSaleLocation::GetByID($ID, LANGUAGE_ID)))
return false;
foreach (GetModuleEvents("sale", "OnBeforeLocationDelete", true) as $arEvent)
if (ExecuteModuleEventEx($arEvent, array($ID))===false)
return false;
if (IntVal($arLocRes["CITY_ID"]) > 0)
CSaleLocation::DeleteCity($arLocRes["CITY_ID"]);
$bDelCountry = True;
$db_res = CSaleLocation::GetList(
array("SORT" => "ASC"),
array("COUNTRY_ID" => $arLocRes["COUNTRY_ID"], "!ID"=>$ID),
LANGUAGE_ID
);
if ($db_res->Fetch())
$bDelCountry = false;
if ($bDelCountry && IntVal($arLocRes["COUNTRY_ID"]) > 0)
CSaleLocation::DeleteCountry($arLocRes["COUNTRY_ID"]);
$bDelRegion = True;
$db_res = CSaleLocation::GetList(
array("SORT" => "ASC"),
array("REGION_ID" => $arLocRes["REGION_ID"], "!ID"=>$ID),
LANGUAGE_ID
);
if ($db_res->Fetch())
$bDelRegion = false;
if ($bDelRegion && IntVal($arLocRes["REGION_ID"]) > 0)
CSaleLocation::DeleteRegion($arLocRes["REGION_ID"]);
$DB->Query("DELETE FROM b_sale_location2location_group WHERE LOCATION_ID = ".$ID."", true);
$DB->Query("DELETE FROM b_sale_delivery2location WHERE LOCATION_ID = ".$ID." AND LOCATION_TYPE = 'L'", true);
$DB->Query("DELETE FROM b_sale_location_zip WHERE LOCATION_ID = ".$ID."", true);
if(self::isLocationProMigrated())
{
try
{
$res = Location\LocationTable::delete($ID); // the whole subtree will be deleted
if(!$res->isSuccess())
return false;
$bDelete = true;
}
catch(Exception $e)
{
return false;
}
}
else
{
$bDelete = $DB->Query("DELETE FROM b_sale_location WHERE ID = ".$ID."", true);
}
foreach (GetModuleEvents("sale", "OnLocationDelete", true) as $arEvent)
ExecuteModuleEventEx($arEvent, array($ID));
return $bDelete;
}