/* 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(); $items = array( array('sku'=>'ITEM SKU AS PER SHIPWIRE ACCOUNT', 'quantity'=>1), array('sku'=>'ITEM SKU AS PER SHIPWIRE ACCOUNT', 'quantity'=>2), ); $isresidential = true; if ($DATA['destination']['company_name'] !== null && $DATA['destination']['company_name'] != '') $isresidential = false; //Shipwire API $SW = new ShipwireAPI('YOUR SHIPWIRE USERNAME','YOUR SHIPWIRE PASSWORD'); $SW->setDestination($DATA['destination']['address1'],$DATA['destination']['address2'],$DATA['destination']['city'],$DATA['destination']['province'],$DATA['destination']['postal_code'],$DATA['destination']['country'],$isresidential); $r = $SW->getRate($items); if ($r) { foreach ($r as $_r) { $_RATES[] = array( "service_name" => $_r['name'], "service_code" => $_r['code'], "total_price" => $_r['amount']*100, //in cents "currency" => "USD", ); } } //END Shipwire API return $_RATES; /* do not edit below this line */ }