Perfect!
Works as expected.
Test out this module for Free
Shipping Costs Based on Distance
Check your email
We've sent a confirmation link. Click it to spin up your demo.
Setting up your demo...
This usually takes a few minutes. You can close this modal or wait for the result — we'll also send you an email when it's ready.
You're in the queue
Position: #
All demo slots are currently in use. You'll receive an email as soon as your demo is ready.
Your demo is ready!
Expires:
Credentials have also been sent to your email.
Something went wrong
We couldn't set up your demo. Please try again or contact support.





Shipping Costs Based on Distance for Magento 2 adds a shipping method that prices delivery by the driving distance between your store address and the delivery address. Google Maps calculates the route by road, not a straight line, from the city, postcode and country the customer enters. Street and house number are not part of the request.
You set the price per distance zone in the admin: a fixed amount, a price per kilometre or mile, or both. In the checkout the customer sees the method with the distance in brackets behind the title, for example "(12.5)".
That suits stores that deliver with their own van or a local courier, where every extra kilometre costs time and fuel.

Google Maps calculates the route from your store address to the city, postcode and country of the customer.
A fixed amount, a price per kilometre or mile, or both, in as many distance zones as you need.
A maximum distance, a minimum order amount, specific countries, a minimum and maximum price and free shipping above an order amount.
A yes/no product attribute decides which products can be delivered with the distance method.
The customer enters a country, city and postcode and sees the distance and the cost before the checkout.
A repeat calculation for the same city, postcode and country comes from the cache and does not cost a new Google request.
All settings are in the Magento configuration under "Magmodules" > "Shipping Costs Based on Distance". In "General" you choose the "Google Maps API Version": "Routes API (Recommended)" or "Distance Matrix API (Legacy)". The default is the Distance Matrix API, the older of the two. Enable the API you select in your Google Cloud Console.
Paste the key in "API Key" and enter the "Store Address", the store or pickup point every distance is measured from. The button "Check Credentials" tests the connection from the configuration page and answers "Credentials correct!" when it works.
The method appears in the checkout once two switches are on: "Enabled" in "General" and "Enabled" under "Name and Position" in "Shipping Method". Both are off after installation.
The extension needs a Google Maps API key from the Google Cloud Platform. The key is stored encrypted in the Magento configuration. Google sets its own request limits and prices, so check the Google Maps Platform pricing for your expected volume.


The group "Shipping Method" holds the calculation under "Calculation and Pricing". You decide how distance is measured, how it is rounded and what each zone costs:
All rows that cover the distance are added up. An example: 0 to 10 km costs a fixed 5.00. From 10.01 to 50 km you charge a fixed 5.00 plus 0.50 per km. A delivery of 20 km then costs 5.00 plus 20 times 0.50, so 15.00. "From" and "To" both count, so start the next zone at 10.01 when rows should not overlap.
A distance that falls in no zone is priced at 0.00. Let the zones connect, save a "Round Distance" that matches the decimals in your table and use "Minimal Price" or "Maximum Distance" from the limit rules as a safety net.
The group "Limit Rules" starts with two rules for the price itself:
In the example an order above 250.00 ships for free, and every other delivery costs between 5.00 and 25.00, whatever the distance. Free shipping goes first: the minimum price is not applied to an order that qualifies.


Three more rules in "Limit Rules" decide where and when the method is offered:
The messages for distance and order amount each have their own "Message" field, so you can tell the customer in your own words why delivery is not available.
The extension adds a yes/no product attribute, "Eligible for Distance Shipping", to the group "Product Details" of your attribute sets. You can filter on it in the product grid. Turn on "Enabled" in the group "Conditions", and "Show Distance Shipping only for eligible products" limits the method to those products. Think of furniture that goes out with your own van while small items ship as a parcel.
With "Allow Distance Shipping for mixed carts" set to Yes, one eligible product in the cart is enough. Set to No, every product in the cart has to be eligible.
"Hide other shipping methods when Distance Shipping is available" removes the other carriers for carts that meet the product conditions in a country you ship to. That check uses the country and the product conditions, not the distance, so the other carriers are also hidden for an address beyond your maximum distance. With "Show Distance Shipping only for eligible products" set to No, it applies to every cart in those countries.


With "Add Shipping Estimation to Product Page" set to Yes, the product page gets an "Estimate shipping" block. The customer selects a country, enters a city and postcode and clicks "Calculate". The block returns the method name, the distance with its unit, for example "(20km)", and the cost behind the label "Excl tax:". The country list follows your country restriction, and if the distance cannot be calculated the customer is asked to verify the data.
When "Conditions" is enabled and "Show Distance Shipping only for eligible products" is set to Yes, the block only appears on eligible products.
In the checkout the shipping method shows the distance in brackets behind its title, so the customer sees what the price is based on. "Title", "Method Name" and "Sort Order" are yours to set.
The estimate uses your price table, the rounding of the total price and the minimum and maximum price. Free shipping, the maximum distance and the minimum order amount are only applied to the actual order in the checkout.
Errors, such as a failed Google API request, are always written to the error log. Turn on "Debug Mode" in "Debug & Logging" to also log the responses from the Google API and from the cache. You then see which distance a calculation used and whether it came from Google or from the cache. The last log records can be opened from the same configuration page.
The button "Run Self-test" and the CLI command bin/magento distancebasedshipping:selftest run the checks of the extension and report a result per check. That gives a developer or agency a first answer before opening a support ticket.

You choose between the Routes API and the Distance Matrix API, and the API key is stored encrypted in the Magento configuration. A successful distance lookup stays in the Magento cache for 24 hours, and failed lookups are not cached. Debug Mode logs the responses from Google and from the cache, and the self-test runs as a button in the admin and as the CLI command bin/magento distancebasedshipping:selftest. Most settings can be set per website and store view. The switch of the shipping method, "Sort Order" and the country settings go down to website level, and "Debug & Logging" is set in the default scope. Version 1.9.0 runs on PHP 7.4 or higher.
You set the price per distance zone and keep the method within the area, the countries and the order size you want to serve. A second store view can use its own address, title and price table. Google sets its own request limits and prices for the Maps API, so check the Google Maps Platform pricing for your expected volume.
Shipping Costs Based on Distance needs a Google Maps API key and is set up in the Magento admin. Magmodules is a plugin developer from the Netherlands and supports every merchant who runs its extensions.
What our customers say
Works as expected.
The service provided by Magmodules has been fantastic, we have complex requirements that they supported us through with patience and diligence. Highly recommended.
Share your experience and help other merchants decide.
Sign in to write a reviewA list of the most frequently asked questions from the Shipping Costs Based on Distance extension for Magento 2. We've tried our best to help you with the installation, configuration and troubleshooting. If you do not find the answer you were looking for, you can always send us a message through this form.
Our plugins are regularly updated to ensure compatibility with the latest Magento release.
Features
Minimum requirements
Note
Bugfixes
Minimum requirements
Quality

This extension is listed on the official Adobe Commerce Marketplace and has passed their review process for code quality, performance and security.
Adobe Marketplace approval means the extension follows Magento coding standards and integrates properly with the platform. Updates go through the same review process.

This extension includes full support for Hyva Themes. All frontend components, widgets and templates work natively with Hyva's Alpine.js and Tailwind CSS stack.
The extension works out of the box on Hyva and is tested with every new Hyva release to ensure continued compatibility.

This extension exposes its data and configuration through Magento's GraphQL API. You can query and mutate data directly from headless frontends or custom applications.
The GraphQL schema follows Magento's conventions and covers all key functionality of the extension. This makes it ready for PWA Studio, Vue Storefront or any other headless setup.

This extension is fully compatible with Adobe Commerce Cloud (Magento Cloud). It works with the read-only filesystem, the build and deploy pipeline and cloud-specific caching layers.
No additional configuration or workarounds are needed for cloud environments. The extension handles static content deployment and config management the same way as on-premise installations.

After purchase you get access to a private Composer repository with personal credentials. Install and update the extension with a single composer command, just like any other dependency.
Your Composer credentials are available in your account dashboard. Updates are published to the repository as soon as a new version is released, so you always have access to the latest version.