skip to Main Content

I’m trying to hide shipping method based on shipping distance or based on radius around shipping origin.

I’ve tried using the plugin WooCommerce Distance Rate Shipping, but it cannot achieve this since it’s adding a shipping method to the shipping zone…

I’m trying to have these conditions:

  • If shipping distance is 50 km and lower, then hide shipping method A
  • If shipping distance is 51 km and higher, then hide shipping method B

Could someone point me in the right direction?

Thanks!

2

Answers


  1. You can achieve it without plugins by defining shipping zones and limit each zone by zip codes. You need to manually calculate each zones radius though.

    Example:
    Step 1: Country Sweden, Zone: Solna, Zip code range: 16900…17331
    (WooCommerce understand 3 dots … as any zip codes from 16900 to 17331
    in this case the distance is less than 50 km so I would define shipping rate A for this area.)
    Step 2: go to calcmaps.com/map-radius/ and draw a circle around areas you want to add so you can define zip code ranges based on distance
    Step 3: define shipping alternatives like Flat rate etc. for each area.
    When customer enter a zip code Woocommerce provide available shipping method based on that zip code.
    it’s one way and requires some works but achievable.

    Login or Signup to reply.
  2. 1st you need algorithm to calculate distance between user entered address and your shop store.

    Search for APIs which can help you in that, most of them use coordinate to addresses to do that. google API is also available. Go through these, it might help –

    https://developers.google.com/maps/documentation/javascript/geometry/
    https://developers.google.com/maps/documentation/javascript/reference#spherical

    If you are supporting multi-vendor AKA multiple(total dynamic) warehouses then this will become necessary.

    But if your store address is fixed one, easiest way is make a zone of addresses which falls under such radius and use existing zone system.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search