Pickup and store locator
Show on the product page where the selected variant can be picked up, list the other stores, and put your stores on a Mapbox map with a search field.
If your store has shops or warehouses where customers pick up their orders, Smootify can show them. On the product page, store-availability says whether the selected variant can be picked up, and where. On a page of its own, store-locator shows every store on a map, with a list the visitor can search. This page covers both.
Note
Both read your Shopify locations that offer local pickup. Add the locations under Settings > Locations, turn on local pickup for each one under Settings > Shipping and delivery, and set each product’s stock per location on the product. The store locator also needs a free Mapbox account, and the Lite or Server plan on your custom domain. On localhost and your *.workers.dev address it works on every plan.
1. Pickup on the product page
Add the element store-availability inside smootify-product. Outside it, the element is removed.
<store-availability>
<div condition="available-at-location">Pick up at <span location="name">Store</span></div>
<div condition="not-available-at-location">Not in stock at <span location="name">Store</span></div>
<div location="pick-up-time">Usually ready in 24 hours</div>
<button type="button" popovertarget="stores">Check other stores</button>
<div id="stores" popover="auto">
<store-location><div location="name">Store</div><div location="address">Address</div><div location="quantity">0</div></store-location>
</div>
</store-availability>The first store. Outside the list, the location attributes show the first pickup location Shopify gives for the selected variant, and they follow the variant as it changes:
| Attribute | What it shows |
|---|---|
location="name" | the location’s name |
location="address" | its address, on several lines |
location="quantity" | how many are available there |
location="pick-up-time" | Shopify’s pickup time, such as “Usually ready in 24 hours” |
location="directions-link" | on a link: a Google Maps route to it |
Its states. Inside store-availability, conditions show what the first location has, and classes follow it. Design these states:
The first store has it
- Condition
available-at-locationshows.- Classes
is-availableonstore-availability,is-available-at-pickuponsmootify-product.
The first store does not have it
- Condition
not-available-at-locationshows.- Classes
is-available-at-pickuponsmootify-product: other stores can still have it.
No store offers pickup for the variant
- Condition
not-available-as-local-pickupshows, elsewhere insmootify-product.- Hidden
store-availability, with all it holds.
The other stores, in the panel
- List
- One
store-locationper store that offers the variant, except the store chosen in a location switcher. It loads when the panel opens. - Button
- Hidden when there is only one location.
The other stores. For a list of every store that offers the variant:
- Inside
store-availability, add a panel: adivwithpopover="auto"and anid, or adialog. - Inside the panel, add the element
store-location: the template of one store, with the samelocationattributes. Smootify copies it once per store, except the store the visitor chose in a location switcher. - Outside the panel, add a
buttonwithpopovertargetset to the panel’sid, such as “Check other stores”. It opens the panel.
Without a panel, the button is removed. Add skeleton="text" inside store-location for a placeholder while it loads. With a dialog, the attributes animation-name, animation-duration and disable-blur on store-availability style its opening, as on the market suggestion.
Every value is in pickup attributes and pickup conditions.
2. A store locator page
Get a Mapbox token. In your Mapbox account, create a token with the default public scopes, and limit it to your site’s addresses (your *.workers.dev address and your domain). Copy it: it is public, and it goes in the page.
Which stores are listed. The list comes from Shopify, not from your site’s content: Smootify asks Shopify for your store’s locations that offer local pickup, up to 200, and makes one store-location per location.
- A location is listed only when, in Shopify, it is active under Settings > Locations, it fulfils online orders (Fulfill online orders from this location), and local pickup is turned on for it under Settings > Shipping and delivery > Local pickup. A warehouse or a shop without local pickup is never listed.
- The name, address and phone are the ones set on the location in Shopify. Change them there: the page follows.
- The map places each store at the coordinates Shopify finds for its address. A location whose address Shopify cannot place stays in the list without a marker.
- Stock does not matter here: the locator lists the stores, not the products they have.
Build the locator. Add the element store-locator with the attribute data-api-key set to your token. Inside it go these parts, each an element with that tag unless the table says otherwise:
| Part | What it is | Without it |
|---|---|---|
map | the map is drawn in it; give it a height in its styles | the store locator is removed |
store-location | the template of one store in the list | there is no list |
map-marker | the marker of each store on the map, designed as you like, such as an icon | the map has no markers |
optional: store-popup | the card that opens over a marker when it is clicked | a click on a marker moves the map and marks its store in the list, with no card |
optional: a <form> with an input named query | searches the list as the visitor types, on any text of the store, such as the city or the postal code | the list is not searched |
optional: an element with condition="no-stores" inside store-locator | shows while no store matches the search | an empty list |
<store-locator data-api-key={mapboxToken}>
<map></map>
<form><input name="query"></form>
<store-location><div location="name">Store</div><div location="address">Address</div><a href="#" location="directions-link">Directions</a></store-location>
<map-marker></map-marker>
<store-popup><div location="name">Store</div></store-popup>
</store-locator>What the visitor gets.
- The browser asks the visitor for their position. With it, the stores are sorted by distance and the map starts there. Without it, the map starts at the first store.
- A click on a store in the list moves the map to it, and the store gets the class
is-active. A click on a marker opens itsstore-popupand marks its store in the list. - The search field filters the list as the visitor types.
Inside store-location and store-popup, location shows name, address, zip, phone (a link with it calls the number), country and directions-link.
Map options, as attributes on store-locator:
data-style: the style URL of a Mapbox Studio style,mapbox://styles/mapbox/light-v11by default;data-initial-zoom: the zoom when the map opens, 13 by default;data-zoom: the zoom when the map moves to a store, 13 by default;data-fit-bounds:trueby default, the map zooms out to show every store;falsekeeps the initial zoom;data-padding: the space kept around the stores when the map fits them, 100 pixels by default.
More in store-locator and its attributes.
Before you publish
Check these first
- The pickup block never shows. No location offers the variant for pickup: turn on local pickup for the location, and check the product’s stock there.
- The “Check other stores” button disappears. There is only one pickup location, or the button has no panel to open inside
store-availability. - The store locator disappears. It has no
data-api-key, nomapelement inside, or the store has no location with local pickup. - A store is missing from the locator. In Shopify, the location is inactive, does not fulfil online orders, or has local pickup turned off.
- The map shows no markers. The
map-markertemplate is missing. - The store locator works on
*.workers.devbut not on your domain. It needs the Lite or Server plan there.