Location Availability

All ContributorsAll Contributors

This app provides availability and shipping information based on the user's location, if available at the session, to have a more accurate result, even without authentication. We recommend using this app along with vtex.shopper-location; you can find more information about this app here.

ShelfShelf

Configuration

  1. Install the Location Availability app by running vtex install [email protected].
  2. Open your store's Store Theme app directory in your code editor.
  3. Add the Location Availability app as a peerDependency in the manifest.json file:
 "peerDependencies": {
+  "vtex.location-availability": "0.x"
 }

Now, you are able to use the blocks exported by the location-availability app:

Availability Summary: product-location-availability

This block summarizes a product's availability and is best used on product shelves. By default it will show the two fastest shipping options (or one shipping option and the fastest in-store pickup option). Alternative configurations are available using the props below:

Prop nameTypeDescriptionDefault value
maxItemsnumberMaximum number of availability options shown per product2
orderByenumSort the availability options by faster or cheaperfaster
pickupFirstbooleanIf available, show in-store pickup before other optionstrue
showDistancestringAdd the necessary measurement options kilometers or milesmiles
showAddressInfobooleanAdds address ZipCode and cityfalse

Example

  ...
  "product-summary.shelf#home": {
    "children": [
      "product-summary-image#home",
      "product-summary-name",
+     "product-location-availability",
      "product-summary-sku-selector",
      "flex-layout.row#product-price"
    ]
  },
+  "product-location-availability": {
+    "props": {
+      "maxItems": 3
+      "orderBy": "cheaper"
+      "pickupFirst": false,
+      "showDistance": "miles",
+      "showAddressInfo": true
+    }
+  }
...

Availability Details

These blocks provide more detailed availability information and are designed for use on the PDP (product details page). Each block's information will automatically update if either the user's location or the selected SKU are changed.

location-context: This block provides the location and availability data which the other blocks display. If you wish to use any of the following blocks, this block must be set as their parent (see example below).

product-location-availability-header: This block displays a header for the availability section, i.e. "Availability for 90210:". It can be configured to style the postal code as a link, if you wish to use this block as a trigger for the ChangeLocation modal from vtex.shopper-location.

Prop nameTypeDescriptionDefault value
styleAsLinkbooleanStyle the user's postal code as a linkfalse

product-location-shipping-options: This block displays the available shipping options for the selected SKU based on the user's current location.

product-location-pickup-options: This block displays the stores which have availability for the selected SKU and that are nearby the user's current location. If more than 3 stores meet this criteria, a "See All Stores" button is also rendered which opens the full list of stores in a modal window when clicked.

Example

...
"flex-layout.col#right-col": {
    "props": {
      "preventVerticalStretch": true,
      "rowGap": 0
    },
    "children": [
      "flex-layout.row#product-name",
      "product-rating-summary",
      "flex-layout.row#list-price-savings",
      "flex-layout.row#selling-price",
      "product-installments",
      "product-separator",
      "product-identifier.product",
      "sku-selector",
      "product-quantity",
      "product-assembly-options",
      "product-gifts",
      "flex-layout.row#buy-button",
+     "location-context",
      "share#default"
    ]
  },
+  "location-context": {
+    "children": [
+      "modal-trigger#location-availability",
+      "flex-layout.row#location-availability"
+    ]
+  },
+  "flex-layout.row#location-availability": {
+    "children": [
+      "product-location-pickup-options",
+      "product-location-shipping-options"
+    ]
+  },
+  "modal-trigger#location-availability": {
+    "children": ["product-location-availability-header", "modal-layout#address"]
+  },
+  "product-location-availability-header": {
+    "props": {
+      "styleAsLink": true
+    }
+  },
...

The above JSON will render an availability section that looks like this:

Availability exampleAvailability example

Customization

In order to apply CSS customizations in this and other blocks, follow the instructions given in the recipe on Using CSS Handles for store customization.

CSS Handles
container
shippingOption
postalCode
regularShippingLabel
regularShipping
time
ETA
firstShippingOption
freeShippingLabel
freeShipping
cannotBeDeliveredLabel
cannotBeDelivered
pickUpLabel
pickUp
getTomorrow
getInDays
availabilityHeader
availabilityHeaderLink
storeListContainer
storeListEmptyMessage
pickupHeader
storeList
pickupItem
pickupName
pickupAddress
pickupCityStateZip
pickupEstimate
pickupUnavailable
seeAllModalButton
seeAllModalButtonText
modalContainer
modalHeader
modalStoreList
shippingListContainer
shippingHeader
shippingListEmptyMessage
shippingList
shippingListItem
shippingDeliveryName
shippingDeliveryEstimate
shippingDeliveryPrice
estimateTranslated
distance
distanceEstimate
pickupMessage
pickupStoreName

Contributors ✨

Thanks goes to these wonderful people:

This project follows the all-contributors specification. Contributions of any kind are welcome!


Did this page help you?