/* use the following snippet to calculate distance between two addresses requires the installation of the Delivery by Distance app by Zapiet https://apps.shopify.com/delivery-rate-by-distance */ $DBD_STORENAME = 'xxx.myshopify.com'; $DBD_API_KEY = 'xxxxxx-xxxxxx-xxxxxx-xxxxxx-xxxxxx'; $dpd = new DBDAPI($DBD_STORENAME,$DBD_API_KEY); $dpd->setOrigin($DATA['origin']['address1'],'',$DATA['origin']['city'],$DATA['origin']['province'],$DATA['origin']['postal_code'],$DATA['origin']['country']); $dpd->setDestination($DATA['destination']['address1'],'',$DATA['destination']['city'],$DATA['destination']['province'],$DATA['destination']['postal_code'],$DATA['destination']['country']); $kilometers = $dpd->getDistance(); //distance returned is in meters