I have a modified shipping extension for opencart, at checkout the mod takes a start postcode that is set in the extension's admin panel(normally store postcode) within shipping modules, it then takes the delivery address postcode and makes a call to google to get the distance between both postcodes, the distance is returned by google and then used to work out shipping costs based on the distance. I need this modified so that rather than use the store postcode set in the admin it gets the billing address postcode and uses that as the start point and the delivery address as the end point. I am sure the billing postcode will be stored in a session variable. The fuction to get the distance is below.
//If this user wants to calculate by address / city
if($this->config->get ( 'use_address_calculation' ) == true)
{
$store_address = str_replace("\n", ",", $this->config->get ( 'config_address' ));
$store_address = str_replace("\r", "", $store_address);
$string = trim($store_address). '&destinations=' . trim ( str_replace ( " ", "", $address ['address_1'].','.$address ['city'] ));
$sResponse = $this->curl_request ( '[login to view URL]', 'origins=' . str_replace ( " ", "",$store_address) . '&destinations=' . trim ( str_replace ( " ", "", $address ['address_1'].','.$address ['city'] ) ) . '&mode=driving&units=' . $this->config->get ( 'zip_distance_units' ) . '&sensor=false' );
$oJSON = json_decode ( $sResponse );
}else
{
$sResponse = $this->curl_request ( '[login to view URL]', 'origins=' . str_replace ( " ", "",$this->config->get ( 'zip_distance_origin' )) . '&destinations=' . trim ( str_replace ( " ", "", $address ['postcode'] ) ) . '&mode=driving&units=' . $this->config->get ( 'zip_distance_units' ) . '&sensor=false' );
$oJSON = json_decode ( $sResponse );
}