Opencart extensions free download · 7 min read · Updated

Store Locator for OpenCart 4: A Find-a-Store Page With Search, Near-Me Sorting and a Free Map (Free Extension)

A free OpenCart store locator built on OpenCart's own locations: search by city or postcode, sort by distance with one tap, and show each store on a map with no API key.

Opencart 4 store locator

Shoppers who want to see a product before buying, pick up an order or get a repair need one thing from your site: which store is closest, and is it open? OpenCart 4 already lets you save store locations, but it only prints them as a plain list on the Contact Us page, with no search, no map and no way to find the nearest one.

This free extension adds an OpenCart store locator page. It reads the locations you already keep in OpenCart, lets visitors search by city or postcode, sorts stores by distance with one tap on “Use my location”, and shows the selected store on a map that needs no API key. Tested on OpenCart 4.1.0.4.

Download: storelocator.ocmod.zip (OpenCart 4.0.2.x to 4.1.x, free, no core file changes)

OpenCart 4 Find a store page with a search box and Use my location button, store cards sorted by distance with 81 mi away and 732 mi away badges, and an OpenStreetMap map of the Chicago store on the right
After “Use my location”, stores are sorted by distance and the nearest one is shown on the map.

What the store locator extension does

  • Adds a Find a store page with every location from System > Localisation > Store Location, or only the ones you tick.
  • Shows each store’s address, phone number, opening hours, comment and image, with Directions and Call buttons.
  • Filters the list as the visitor types a city, postcode or store name.
  • Sorts stores by distance when the visitor taps Use my location, in miles or kilometers. The position stays in the browser.
  • Shows the selected store on an OpenStreetMap map. No Google Maps API key or billing account.
  • Adds a “Find a store” link to the footer and a /store-locator SEO URL.
  • Adds schema.org Store structured data for each location.

Install the extension

  1. Download storelocator.ocmod.zip.
  2. Go to Extensions > Installer, click Upload and choose the zip.
  3. Go to Extensions > Extensions, choose Modules, find Store Locator and click Install.
  4. Click Edit, switch Status on and click Save.

Add your stores

The stores are OpenCart’s own locations, so there is nothing new to learn. Go to System > Localisation > Store Location and add one entry per store: name, address, telephone, opening times and an optional image and comment.

The one field that matters for the map and the distance sorting is Geocode. OpenCart only says “Please enter your store location geocode manually”, so enter it as latitude,longitude, for example 41.8781,-87.6298. In Google Maps, right-click the store and click the coordinates to copy them. In OpenStreetMap, right-click and choose “Show address”.

OpenCart 4 Store Location form for Webo Store New York with store name, address, geocode 40.7484,-73.9857, telephone, image, opening times and comment fields
A store is a normal OpenCart location. The geocode is latitude and longitude separated by a comma.

A store without a usable geocode is still listed with its address, hours and a Directions button that searches for the address. It just has no map and no distance.

Settings

Store Locator settings in OpenCart 4 admin with page heading and introduction, a table of stores with Geocode OK badges and a warning for a store with no usable geocode, and switches for footer link, Use my location, distance unit, map and structured data
The settings page flags any store whose geocode the locator can’t use.
  • Page heading and Introduction, per language.
  • Stores to show: tick the locations to list. Leave every box unticked to show all of them. Each row shows “Geocode OK” or a warning, with an edit button.
  • Footer link: adds “Find a store” to the Information column of the footer.
  • “Use my location” button and Distance unit (miles or kilometers).
  • Map: the OpenStreetMap map next to the list.
  • Store structured data: the schema.org markup described below.

How the OpenCart store locator works

It reads OpenCart’s own locations

There is no extra table to keep in sync. The model reads the core location table, filtered to the ticked stores:

public function getLocations(array $location_ids = []): array {
	$sql = "SELECT `location_id`, `name`, `address`, `telephone`, `geocode`, `image`, `open`, `comment` FROM `" . DB_PREFIX . "location`";

	$location_ids = array_filter(array_map('intval', $location_ids));

	if ($location_ids) {
		$sql .= " WHERE `location_id` IN (" . implode(',', $location_ids) . ")";
	}

	$sql .= " ORDER BY `name` ASC";

	return $this->db->query($sql)->rows;

Because the core geocode field is free text, the controller only accepts a real latitude and longitude:

private function parseGeocode(string $geocode): array {
	if (preg_match('/^\s*(-?\d{1,2}(?:\.\d+)?)\s*,\s*(-?\d{1,3}(?:\.\d+)?)\s*$/', $geocode, $match) && abs((float)$match[1]) <= 90 && abs((float)$match[2]) <= 180) {
		return [(float)$match[1], (float)$match[2]];
	}

	return [];

“Use my location” never leaves the browser

The button asks the browser for the visitor’s position and works out the straight-line distance to each store with the haversine formula. Nothing is sent to your server and nothing is stored, so there is no personal data to declare beyond what the browser itself asks permission for:

  // Distance on a sphere (haversine). Runs only in the browser; the position is never sent anywhere.
  function distance(lat1, lng1, lat2, lng2) {
    var r = labels.unit === 'mi' ? 3958.8 : 6371, rad = Math.PI / 180;
    var a = Math.pow(Math.sin((lat2 - lat1) * rad / 2), 2) + Math.cos(lat1 * rad) * Math.cos(lat2 * rad) * Math.pow(Math.sin((lng2 - lng1) * rad / 2), 2);

    return 2 * r * Math.asin(Math.sqrt(a));

If the visitor says no, or the browser can’t get a position, the page shows “We could not get your location. Search by city or postcode instead.” Browsers only offer location on HTTPS pages (and on localhost while you develop).

A map without an API key

The map is OpenStreetMap’s embed page in an iframe, pointed at the selected store. Clicking Show on map on another store only changes the iframe’s address:

    var lat = parseFloat(store.dataset.lat), lng = parseFloat(store.dataset.lng), d = 0.01;

    map.src = 'https://www.openstreetmap.org/export/embed.html?bbox=' + [lng - d * 1.6, lat - d, lng + d * 1.6, lat + d].map(function (n) { return n.toFixed(5); }).join('%2C') + '&layer=mapnik&marker=' + lat.toFixed(5) + '%2C' + lng.toFixed(5);

The map loads from openstreetmap.org, so add it to your privacy policy, and switch the map off if you would rather not load third-party content. A link such as /store-locator#store-3 opens the page with that store selected.

Structured data for each store

Each location is described as a schema.org Store with its name, address, phone and coordinates. This helps search engines and AI assistants understand which addresses belong to your business. It doesn’t guarantee any special search result, and for your main locations a Google Business Profile matters more:

$store = [
	'@type'   => 'Store',
	'@id'     => $schema_url . '#store-' . (int)$location['location_id'],
	'name'    => $name,
	'address' => preg_replace('/\s*\n\s*/', ', ', trim($address)),
	'url'     => $schema_url . '#store-' . (int)$location['location_id']
];

if ($telephone !== '') {
	$store['telephone'] = $telephone;
}

if ($geo) {
	$store['geo'] = ['@type' => 'GeoCoordinates', 'latitude' => $geo[0], 'longitude' => $geo[1]];
}

if ($image) {
	$store['image'] = $image;
}

$schema[] = $store;

A catalog/view/common/footer/before event adds the page to the footer’s Information links, so it works with the default theme and with themes that keep the core footer data, such as the Webocreation Theme:

OpenCart 4 store footer with a Find a store link at the bottom of the Information column, under Useful links
“Find a store” is added to the Information column.

Search and phones

Typing filters the list at once. Searching “san” leaves only the San Francisco store, and the map jumps to it:

Find a store page filtered by the search term san, showing only Webo Store San Francisco with its address, phone, opening hours and a map of San Francisco
The search matches store names and addresses, including postcodes.

On phones the list comes first and the map moves below it. Show on map scrolls down to the map.

Find a store page on a phone with the heading, introduction, full-width search box, Use my location button and the first store card
The phone layout stacks the search, the stores and the map.

What we found when testing

We tested on OpenCart 4.1.0.4 with five demo locations: four with coordinates and a weekend pop-up with no geocode.

  • With the browser position set to Milwaukee, “Use my location” put Chicago first at 81 miles, then New York at 732 and Austin at 1,036. The pop-up with no geocode went to the end with no distance.
  • When the location permission was denied, the page showed the fallback message and kept the alphabetical list.
  • OpenStreetMap’s embed draws its map with WebGL. Headless Chrome without a GPU showed “your browser does not support WebGL” instead of the map. Normal browsers are fine.
  • The extension adds the store-locator keyword on install and removes it on uninstall. Pretty URLs such as /en-gb/store-locator only work after you rename OpenCart’s .htaccess.txt to .htaccess, the same as for every other SEO URL.
  • Uninstalling removes the footer event, the SEO URL and the settings. Your locations stay, because they belong to OpenCart.

Limitations

  • Distances are straight lines, not driving distances. The Directions button hands the trip to Google Maps.
  • Search matches text in the name and address. It doesn’t geocode a postcode, so “60602” won’t find a store whose address says “60601”.
  • The map shows one store at a time, not every store as pins on one map.
  • Opening hours are the free-text “Opening Times” field, so the page can’t say “open now”.
  • If your store gets heavy traffic, read OpenStreetMap’s tile usage policy before relying on the embed.
Rupak Nepali
Written byRupak Nepali

Rupak Nepali is a web developer, manage Webocreation website and the author of six books:
Getting Started with OpenCart Module Development (Packt, 2013),
OpenCart Theme and Module Development (Packt, 2015),
OpenCart 4: Dev Guide for Themes & Extensions (2024),
OpenCart 4: User Manual (2025),
Cloudflare for the Enterprise Website (2026) and
The Technical Web Guide for Marketers (2026).
Rupak has built OpenCart stores and extensions since 2010, has published more than 600 tutorials on Webocreation, and shares free OpenCart extensions on GitHub.
Find Rupak on
GitHub | Amazon | LinkedIn | X | YouTube.

Leave a Reply

Your email address will not be published. Required fields are marked *