本文整理汇总了PHP中CSaleLocation::UpdateCountry方法的典型用法代码示例。如果您正苦于以下问题:PHP CSaleLocation::UpdateCountry方法的具体用法?PHP CSaleLocation::UpdateCountry怎么用?PHP CSaleLocation::UpdateCountry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSaleLocation
的用法示例。
在下文中一共展示了CSaleLocation::UpdateCountry方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Update
//.........这里部分代码省略.........
* @return int <p>Возвращается код измененного местоположения или <i>false</i> у
* случае ошибки.</p> <a name="examples"></a>
*
*
* <h4>Example</h4>
* <pre>
* <?
* $arFields = array(
* "SORT" => 100,
* "COUNTRY_ID" => 8,
* "WITHOUT_CITY" => "N"
* );
*
* $arCity = array(
* "NAME" => "Kaliningrad",
* "SHORT_NAME" => "Kaliningrad",
* "ru" => array(
* "LID" => "ru",
* "NAME" => "Калининград",
* "SHORT_NAME" => "Калининград"
* ),
* "en" => array(
* "LID" => "en",
* "NAME" => "Kaliningrad",
* "SHORT_NAME" => "Kaliningrad"
* )
* );
*
* $arFields["CITY"] = $arCity;
*
* if (!CSaleLocation::Update(6, $arFields))
* echo "Ошибка изменения местоположения";
* ?>
* </pre>
*
*
* @static
* @link http://dev.1c-bitrix.ru/api_help/sale/classes/csalelocation/csalelocation__update.a6601f1c.php
* @author Bitrix
*/
public static function Update($ID, $arFields)
{
global $DB;
if (!CSaleLocation::CheckFields("UPDATE", $arFields)) {
return false;
}
if (!($arLocRes = CSaleLocation::GetByID($ID, LANGUAGE_ID))) {
return false;
}
if ((!is_set($arFields, "COUNTRY_ID") || IntVal($arFields["COUNTRY_ID"]) <= 0) && $arFields["COUNTRY_ID"] != "") {
$arFields["COUNTRY_ID"] = CSaleLocation::AddCountry($arFields["COUNTRY"]);
if (IntVal($arFields["COUNTRY_ID"]) <= 0) {
return false;
}
unset($arFields["CITY_ID"]);
unset($arFields["REGION_ID"]);
CSaleLocation::AddLocation($arFields);
} elseif ($arFields["CHANGE_COUNTRY"] == "Y" || $arFields["COUNTRY_ID"] == "") {
CSaleLocation::UpdateCountry($arFields["COUNTRY_ID"], $arFields["COUNTRY"]);
}
//city
if ($arFields["WITHOUT_CITY"] != "Y") {
if (IntVal($arLocRes["CITY_ID"]) > 0) {
CSaleLocation::UpdateCity(IntVal($arLocRes["CITY_ID"]), $arFields["CITY"]);
} else {
$arFields["CITY_ID"] = CSaleLocation::AddCity($arFields["CITY"]);
if (IntVal($arFields["CITY_ID"]) <= 0) {
return false;
}
}
} else {
CSaleLocation::DeleteCity($arLocRes["CITY_ID"]);
$arFields["CITY_ID"] = false;
}
//region
if (IntVal($arFields["REGION_ID"]) > 0) {
CSaleLocation::UpdateRegion(IntVal($arLocRes["REGION_ID"]), $arFields["REGION"]);
} elseif ($arFields["REGION_ID"] == 0 && $arFields["REGION_ID"] != '') {
$db_res = CSaleLocation::GetRegionList(array("ID" => "DESC"), array("NAME" => $arFields["REGION"][LANGUAGE_ID]["NAME"]));
$arRegion = $db_res->Fetch();
if (count($arRegion) > 1) {
$arFields["REGION_ID"] = $arRegion["ID"];
} else {
$arFields["REGION_ID"] = CSaleLocation::AddRegion($arFields["REGION"]);
if (IntVal($arFields["REGION_ID"]) <= 0) {
return false;
}
$arFieldsTmp = $arFields;
unset($arFieldsTmp["CITY_ID"]);
CSaleLocation::AddLocation($arFieldsTmp);
}
} elseif ($arFields["REGION_ID"] == '') {
//CSaleLocation::DeleteRegion($arLocRes["REGION_ID"]);
$arFields["REGION_ID"] = 0;
} else {
unset($arFields["REGION_ID"]);
}
CSaleLocation::UpdateLocation($ID, $arFields);
return $ID;
}
示例2: Update
function Update($ID, $arFields)
{
global $DB;
if (!CSaleLocation::CheckFields("UPDATE", $arFields)) return false;
if (!($arLocRes = CSaleLocation::GetByID($ID, LANGUAGE_ID))) return false;
if(self::isLocationProMigrated())
{
try
{
// only partial support: name update functionality
if(($arFields["CHANGE_COUNTRY"]=="Y" || intval($arFields["COUNTRY_ID"])) && is_array($arFields["COUNTRY"]))
CSaleLocation::UpdateCountry($arFields["COUNTRY_ID"], $arFields["COUNTRY"]);
if(intval($arFields["REGION_ID"]) && is_array($arFields["REGION"]))
CSaleLocation::UpdateRegion($arFields["REGION_ID"], $arFields["REGION"]);
if(intval($arFields["CITY_ID"]) && is_array($arFields["CITY"]))
CSaleLocation::UpdateCity($arFields["CITY_ID"], $arFields["CITY"]);
}
catch(Exception $e)
{
return false;
}
}
else
{
if ((!is_set($arFields, "COUNTRY_ID") || IntVal($arFields["COUNTRY_ID"])<=0) && $arFields["COUNTRY_ID"] != "")
{
$arFields["COUNTRY_ID"] = CSaleLocation::AddCountry($arFields["COUNTRY"]);
if (IntVal($arFields["COUNTRY_ID"])<=0) return false;
UnSet($arFields["CITY_ID"]);
UnSet($arFields["REGION_ID"]);
CSaleLocation::AddLocation($arFields);
}
elseif ($arFields["CHANGE_COUNTRY"]=="Y" || $arFields["COUNTRY_ID"] == "")
{
CSaleLocation::UpdateCountry($arFields["COUNTRY_ID"], $arFields["COUNTRY"]);
}
//city
if ($arFields["WITHOUT_CITY"]!="Y")
{
if (IntVal($arLocRes["CITY_ID"])>0)
{
CSaleLocation::UpdateCity(IntVal($arLocRes["CITY_ID"]), $arFields["CITY"]);
}
else
{
$arFields["CITY_ID"] = CSaleLocation::AddCity($arFields["CITY"]);
if (IntVal($arFields["CITY_ID"])<=0) return false;
}
}
else
{
CSaleLocation::DeleteCity($arLocRes["CITY_ID"]);
$arFields["CITY_ID"] = false;
}
//region
if (IntVal($arFields["REGION_ID"])>0)
{
CSaleLocation::UpdateRegion(IntVal($arLocRes["REGION_ID"]), $arFields["REGION"]);
}
elseif ($arFields["REGION_ID"] == 0 && $arFields["REGION_ID"] != '')
{
$db_res = CSaleLocation::GetRegionList(array("ID" => "DESC"), array("NAME" => $arFields["REGION"][LANGUAGE_ID]["NAME"]));
$arRegion = $db_res->Fetch();
if (count($arRegion) > 1)
$arFields["REGION_ID"] = $arRegion["ID"];
else
{
$arFields["REGION_ID"] = CSaleLocation::AddRegion($arFields["REGION"]);
if (IntVal($arFields["REGION_ID"])<=0)
return false;
$arFieldsTmp = $arFields;
UnSet($arFieldsTmp["CITY_ID"]);
CSaleLocation::AddLocation($arFieldsTmp);
}
}
elseif ($arFields["REGION_ID"] == '')
{
//CSaleLocation::DeleteRegion($arLocRes["REGION_ID"]);
$arFields["REGION_ID"] = 0;
}
else
{
UnSet($arFields["REGION_ID"]);
}
CSaleLocation::UpdateLocation($ID, $arFields);
return $ID;
}
//.........这里部分代码省略.........