> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.weltpixel.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# How to Configure Distance Priority Algorithm for In-Store Delivery in Magento 2

## How to Configure Distance Priority Algorithm for In-Store Delivery in Magento 2

The **Distance Priority Algorithm** allows Magento to calculate and suggest the nearest source location to ship an order based on the customer’s shipping address. This ensures faster and more efficient deliveries.

---

### Step 1: Navigate to Inventory Settings

In your Magento Admin Panel, go to:

**Admin → Stores → Settings → Configuration → Catalog → Inventory**

---

### Step 2: Configure Distance Provider for Distance-Based SSA

You’ll find an option labeled **Distance Provider for Distance Based SSA.** Here, you can choose from:

- **Google Maps** – Recommended for real-time, accurate results. [Set up Google Maps Platform](https://cloud.google.com/maps-platform/)
- **Offline Calculations** – Requires downloading and importing geocodes via command-line. This method is better handled with the help of a developer.

![magento2-configure-distance-priority-algorithm.png](https://storage.crisp.chat/users/helpdesk/website/-/d/6/2/8/d6289a88aad9b800/899edc34-ebfd-4887-b3c3-ea7d0b_14xmcpp.png)

Click **Save Config** after making your selection.

---

### Step 3: Configure Google Distance Provider (If Selected)

If you selected **Google Maps**, you need to ensure that the following APIs are enabled on your Google API key:

- [Geocoding API](https://developers.google.com/maps/documentation/geocoding/start)
- [Distance Matrix API](https://developers.google.com/maps/documentation/distance-matrix/start)

#### Computation Mode Options:

- **Driving (Default):** Uses standard driving directions via the road network.
- **Walking:** Uses pedestrian paths and sidewalks where available.
- **Bicycling:** Uses cycling routes and pedestrian-friendly paths where available.

#### Value Options:

- **Distance (Default):** Returns the distance between points in kilometers/meters or miles/feet.
- **Time to Destination:** Returns the estimated travel time between the source and shipping address.

When finished, click **Save Config** to apply your changes.

---

✅ With this setup, Magento will automatically use the distance priority algorithm to determine the closest source for fulfilling orders, enhancing delivery efficiency.