K
K
k-22017-10-03 13:52:37
PHP
k-2, 2017-10-03 13:52:37

How to change the address depending on the city in opencart?

https://samara.omatras.ru/p_contacts/
here, depending on the city, the phone number and address change. How can this be done in opencart?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2017-10-03
@K-2

To begin with, create all possible address options for the store and with cities (if you still write all the code where and how to use models, controllers and display, there will be a lot of text), and already add ip check to the controller code:
$geoposition = file_get_contents( ' api.sypexgeo.net/json "your user's ip will be here"');
$geoposition = json_decode($geoposistion);
From the result, pull out the name of the city and compare it with what you have in the database and display the desired address on the page, I think it will not be difficult

D
djnick, 2018-11-04
@djnick

There is a geoip pro module like for opencart, it costs 700r. The FIAS base of cities and regions is already sewn into it.
It has such a thing as a geomessage depending on the region, city, geofence.
And then it’s easier than ever in a controller or even in a tpl, you can make correspondence if a geomessage is such and such, display such and such an address ...
If without third-party modules, then configure geofences, add a correspondence table for IP address and phone number, and do the check in controller.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question