Geolocation
To show a delivery date, the module has to know where the visitor is. This page explains how it works out, how to make it instant, and how to stop it happening at all when it is not needed.
Available since v4.3
Overview
Delivery dates depend on destination. A carrier that reaches Madrid in one day may take four to reach the Canary Islands, and may not deliver to Norway at all. So before the module can show anything, it needs the visitor's country — and, if you deliver by state or region, their region too.
Most of the time it never has to ask. The module works through the cheapest sources first and stops at the first one that answers:
- The customer's own address. If they are logged in, or have an address on their cart, that is where the order is going. Nothing beats it, and nothing else is consulted.
- Your CDN. If your shop sits behind CloudFlare, CloudFront, Akamai, Google App Engine or a proxy running a GeoIP module, the country was already worked out before the request reached your shop. Reading it costs nothing.
- A local database, if you install one. Around two tenths of a millisecond, and the visitor's IP address never leaves your server. See below.
- Free online services, as a last resort. Accurate, but each one is a round trip over the internet, typically a tenth of a second.
If every source fails, the module falls back to your shop's default country rather than showing nothing. A visitor never sees a blank space because a geolocation service was having a bad day.
The result is remembered for the rest of the visit, so the work happens at most once per visitor — and a failure is remembered too, briefly, so an outage costs one attempt rather than one per page.
When detection is skipped entirely
If every active carrier in your shop already covers every active zone, then knowing where a visitor is cannot change which carriers or dates they see. The module notices this and skips detection completely.
This is automatic and needs no configuration. It switches itself back on the moment you add a carrier restricted to particular zones. You can always see which applies: the Diagnostics panel reports whether detection is active, not needed, or turned off.
Installing a local database
A local database makes detection instant and stops the module contacting anyone at all. It is optional — the module works without it — but on a busy shop it is the single biggest speed-up available, and it keeps visitor IP addresses on your own server.
- Go to the Advanced tab, then Geolocation.
- Find the Local country database panel.
- Choose a source in Local database source and click Download the database now.
The download takes up to a minute and is about 8 MB. If it fails, nothing changes: the module carries on using online lookups exactly as before. The file is never installed automatically, never fetched while a customer is browsing, and never included in the module package — it is downloaded to your shop, at your request.
Which source to choose
| DB-IP Lite | MaxMind GeoLite2 | |
|---|---|---|
| Account needed | No | Yes, free |
| Knows countries | Yes | Yes |
| Knows regions and states | No | Yes |
| Updated | Monthly | Weekly |
| Size | About 8 MB | Larger |
DB-IP Lite is the recommended choice and needs nothing from you but a click.
MaxMind asks for an account ID and a licence key, both free from maxmind.com. Both are ordinary settings of the Geolocation section: you save them with the page's Save button, and the download button only downloads. The reason is licensing: MaxMind grants the data to you, not to us, so the download happens with your credentials and the data belongs to your shop. Choose it if you deliver by state or region, since it is the only one of the two that carries region codes.
If you deliver by state and install the country-only database, the module tells you so in the panel, and keeps resolving regions online rather than pretending a country is a region.
Keeping it current
The panel shows when the data was built — not when you downloaded it, which can be very different — and warns you when it is getting old. Re-downloading replaces it. The old file stays in place until the new one has been opened and checked, so an interrupted download cannot break detection.
Turning detection off
If your delivery dates do not depend on destination, you can switch detection off completely: Advanced > Geolocation > Disable geolocation. Every visitor is then treated as being in your shop's default country.
Everything on this page lives in that one section: whether detection runs, whether zones are resolved by country or by state, and which local database answers the lookup.
Privacy
An IP address is personal data under the GDPR, and the free online services are third parties, most of them outside the EU.
Installing a local database removes that entirely: detection happens on your own server and no visitor data is sent anywhere. For shops in the EU this is the recommended setup, and combined with the skip described above, many shops end up making no external calls at all.
If you use the DB-IP database, its licence asks for an attribution, which the module displays in the panel.
Files
| File | Purpose |
|---|---|
classes/EDIpGeolocationHelper.php | Works through the sources in order |
classes/EDGeoDatabase.php | Reads the local database |
classes/EDGeoDatabaseUpdater.php | Downloads and installs it |
classes/EDHttpTransport.php | Outbound requests, with a strict time budget |
views/templates/admin/geodatabase.tpl | The back office panel |
geoip/ | Where the downloaded database lives |
Settings
| Setting | Default | What it does |
|---|---|---|
ED_GEODB_SOURCE | dbip | Which database to download |
ED_GEODB_MAXMIND_ACCOUNT | empty | Your MaxMind account ID |
ED_GEODB_MAXMIND_KEY | empty | Your MaxMind licence key |
ED_DISABLE_GEOLOCATION | off | Skip detection, always use the default country |
ED_SHIPPING_TYPE | country | Whether zones are resolved by country or by state |
ED_FORCE_COUNTRY | off | Resolve zones by country even in state mode |
Notes
- Detection never delays a page by more than about six tenths of a second, even if every online service is down.
- On PrestaShop 1.6 the local database is not available, because that version does not include the reader library. Detection works normally through the other sources.
- In a multi-shop setup each shop has its own settings, and the database is shared.