> For the complete documentation index, see [llms.txt](https://support.morozovpimnev.ru/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://support.morozovpimnev.ru/megapost/gorod-dlya-rascheta.md).

# Город для расчета

Если вы все сделали как в [Настройки макета](/megapost/nastroiki-maketa.md) и указали код **MegaPost\_GeoIp::getCountryLocationCity()**, то при первом заходе в сессию (ASMP\_City) посетителя сохраняется вся информацию по его местоположению для дальнейшего расчета доставок, при любом изменении города сессия перезаписывается

{% code lineNumbers="true" fullWidth="true" %}

```php
print_r($_SESSION['ASMP_City']);

/*
Array
(
    [ip] => 192.168.0.1
    [city] => Екатеринбург
    [region] => Свердловская область
    [country_iso] => RU
    [country] => Россия
    [shop_country_id] => 175
    [shop_country_location_id] => 55
    [region_id] => 66
    [region_kladr] => 6600000000000
    [shop_country_location_city_id] => 1888
    [postcode] => 620033
    [kladr] => 6600000100000
)
*/
```

{% endcode %}

Если вы хотите подставить свой город, то можно сделать следующее, после вызова **MegaPost\_GeoIp::getCountryLocationCity()**, разместите следующий код

{% tabs %}
{% tab title="из справочника HostCMS" %}
{% code lineNumbers="true" fullWidth="true" %}

```php
if(!isset($_SESSION['ASMP_City']))
{
    $oShop_Country_Location_City = Core_Entity::factory('Shop_Country_Location_City', 123); // где 123 - ID города
    $_SESSION['ASMP_City'] = MegaPost_GeoIp::makeCity($oShop_Country_Location_City);
}

MegaPost_GeoIp::getCountryLocationCity();
```

{% endcode %}
{% endtab %}

{% tab title="любой другой город" %}
{% code lineNumbers="true" fullWidth="true" %}

```php
if(!isset($_SESSION['ASMP_City']))
{
    $aReturn = array(
        'city' => 'Екатеринбург',
        'region' => 'Свердловская область',
        'country' => 'Россия',
        'country_iso' => 'RU',
        'kladr' => 6600000100000,
        'region_kladr' => 6600000000000,
        'region_id' => 66,
    );
    
    $_SESSION['ASMP_City'] = $aReturn;
}

MegaPost_GeoIp::getCountryLocationCity();
```

{% endcode %}
{% endtab %}
{% endtabs %}
