/* This macro will be parsed as PHP code (see http://www.php.net) The calculateshipping function is called every time a shipping calculation request is made by Shopify. The function must return an array of available shipping options, otherwise no shipping options will be returned to your customers. */ function calculateshipping($DATA) { /* do not edit above this line */ $_RATES = array(); $_SENDLE_ID = 'YOUR SENDLE ID'; $_SENDLE_KEY = 'YOUR SENDLE API KEY'; $SD = new SendleAPI($_SENDLE_ID,$_SENDLE_KEY); $SD->setOrigin($DATA['origin']['city'],$DATA['origin']['postal_code'],$DATA['origin']['province'],$DATA['origin']['country']); $SD->setDestination($DATA['destination']['city'],$DATA['destination']['postal_code'],$DATA['destination']['province'],$DATA['destination']['country']); $packages = array( array('weight'=>10), ); $r = $SD->getRate($packages); if ($r) { foreach ($r as $_r) { $_RATES[] = array( "service_name" => $_r['name'], "service_code" => $_r['code'], "total_price" => $_r['amount']*100, //in cents "currency" => "AUD", ); } } return $_RATES; /* do not edit below this line */ }