Documentation

AddCity

This class has been deprecated. It's recommended to use methods of class Bitrix\Sale\Location.

int
CSaleLocation::AddCity(
  array arFields
);

The method AddCity adds a new city.

Parameters

ParameterDescription
arFields Associated array with parameters of the city to be added. The following keys are possible:
  • NAME - the city name (language-independent);
  • SHORT_NAME - city name abbreviation (language-independent);
  • <language ID> - the key is the language name. The value is an associated array in the format:
    array("LID" => "language ID",
          "NAME" => "city name in this language",
          "SHORT_NAME" => "city name abbreviation 
                           in this language").
    Such pair must be specified for every language in the system.

Returned values

Returns the new city ID on success, or false otherwise.

Example


<?
$arCity = array(
   "NAME" => "Paris",
   "SHORT_NAME" => "Paris",
   "fr" => array(
      "LID" => "fr",
      "NAME" => "Paris",
      "SHORT_NAME" => "Paris"
      ),
   "en" => array(
      "LID" => "en",
      "NAME" => "Paris",
      "SHORT_NAME" => "Paris"
      )
);

$ID = CSaleLocation::AddCity($arCity);
if (IntVal($ID)<=0)
   echo "Error adding city";
?>

© «Bitrix24», 2001-2024
Up