2.0 Beta

Smootify 2.0 is in public beta. Your 1.x store keeps working. Move when you want.

What changed

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.

v2.0 beta
Open .md
On this page
  1. 1. Pickup on the product page
  2. 2. A store locator page
  3. Before you publish

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:

AttributeWhat 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-location shows.
Classes
is-available on store-availability, is-available-at-pickup on smootify-product.

The first store does not have it

Condition
not-available-at-location shows.
Classes
is-available-at-pickup on smootify-product: other stores can still have it.

No store offers pickup for the variant

Condition
not-available-as-local-pickup shows, elsewhere in smootify-product.
Hidden
store-availability, with all it holds.

The other stores, in the panel

List
One store-location per 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:

  1. Inside store-availability, add a panel: a div with popover="auto" and an id, or a dialog.
  2. Inside the panel, add the element store-location: the template of one store, with the same location attributes. Smootify copies it once per store, except the store the visitor chose in a location switcher.
  3. Outside the panel, add a button with popovertarget set to the panel’s id, 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:

PartWhat it isWithout it
mapthe map is drawn in it; give it a height in its stylesthe store locator is removed
store-locationthe template of one store in the listthere is no list
map-markerthe marker of each store on the map, designed as you like, such as an iconthe map has no markers
optional: store-popupthe card that opens over a marker when it is clickeda click on a marker moves the map and marks its store in the list, with no card
optional: a <form> with an input named querysearches the list as the visitor types, on any text of the store, such as the city or the postal codethe list is not searched
optional: an element with condition="no-stores" inside store-locatorshows while no store matches the searchan 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 its store-popup and 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-v11 by 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: true by default, the map zooms out to show every store; false keeps 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, no map element 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-marker template is missing.
  • The store locator works on *.workers.dev but not on your domain. It needs the Lite or Server plan there.

    ↑ ↓ to moveEnter to openEsc to close