P
P
photosho2019-09-16 15:33:07
1C-Bitrix
photosho, 2019-09-16 15:33:07

How to find out the city where the site visitor is located?

The site has a catalog distributed over several cities. City is a category of the catalog infoblock: if the city ID is present in the address bar, then only materials from this category are displayed. There are 3 cities in total. Also, the page has a city selection list, in which the page is reloaded with the corresponding parameter when it is changed.
The client wants the page to automatically determine if the visitor is from a city in the list - in this case, this city must initially be selected in the list. How can such a thing be implemented?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yaroslav Alexandrov, 2019-09-16
@photosho

It will be necessary to make improvements:
1) Geo IP - a free module on the marketplace olegpro.ipgeobase is a good module
- get the city by IP and if it matches, substitute the desired directory category
2) Plus cookies - remember the city on the first visit and store the city. If the city is selected manually, also store in cookies.
https://www.php.net/manual/en/features.cookies.php

F
freelion93, 2019-09-16
@freelion93

HTML5 has a Geolocation function , get the coordinates and visualize even on the map even with text

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question