Title: Reuse GMW&#8217;s code to develop shipping method
Last modified: November 24, 2018

---

# Reuse GMW’s code to develop shipping method

 *  [Bob](https://wordpress.org/support/users/shallway/)
 * (@shallway)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/reuse-gmws-code-to-develop-shipping-method/)
 * Hello,
 * I’d like to develop a customized shipping method based on customer-vendor distance.
   I’m thinking maybe I could use GMW’s code. E.g. a function that I could call 
   from my shipping method Class – something like GMW_calculate_distance($address1,
   $address2), $address1 and $address2 being two addresses in natural language.
 * I’m not familiar with GMW’s code, could you give me some help on how I can write
   the code before I dive too deep?
 * Thanks,
    Shawn

Viewing 1 replies (of 1 total)

 *  Plugin Author [Eyal Fitoussi](https://wordpress.org/support/users/ninjew/)
 * (@ninjew)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/reuse-gmws-code-to-develop-shipping-method/#post-10915322)
 * Hi Shawn,
 * You could use the function gmw_calculate_distance() for your purpose, but it 
   does not accept addresses ( since distance can be calculated by coords only ).
   You will need to pass the coordinates of both locations. Like:
 *     ```
       gmw_calculate_distance( $start_lat, $start_lng, $end_lat, $end_lng, $units );
       ```
   
 * Where you pass the latitude and longitude of both the start and end addresses.
   The last value can be ‘k’ for kilometers or ‘m’ for miles.
 * If you are using locations that already exist in GEO my WP database, then you
   could pull the coordinates from there. Otherwise, you could use GEO my WP geocoder
   function to geocode the addresses and then pass the coordinates into the function.
 * If you’d provide more info about the addresses and the version of GEO my WP that
   you are currently using, I might be able to provide some more details.

Viewing 1 replies (of 1 total)

The topic ‘Reuse GMW’s code to develop shipping method’ is closed to new replies.

 * ![](https://ps.w.org/geo-my-wp/assets/icon-256x256.gif?rev=2803407)
 * [GEO my WP](https://wordpress.org/plugins/geo-my-wp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/geo-my-wp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/geo-my-wp/)
 * [Active Topics](https://wordpress.org/support/plugin/geo-my-wp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/geo-my-wp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/geo-my-wp/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Eyal Fitoussi](https://wordpress.org/support/users/ninjew/)
 * Last activity: [7 years, 6 months ago](https://wordpress.org/support/topic/reuse-gmws-code-to-develop-shipping-method/#post-10915322)
 * Status: not resolved