/* 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(); $_OAKH_EMAIL = 'ACCOUNT EMAIL ADDRESS'; $_OAKH_KEY = 'YOUR ACOUNT KEY'; $packages = array( array('class'=>50, 'weight'=>350), array('class'=>175, 'weight'=>1025), ); $options = array( 'Pieces'=>25, //set number of pieces //optional extras 'EnhancedServices' => array( array('service'=>'NOTIFY'), //notifications ), ); $OH = new OAKHAPI($_OAKH_EMAIL,$_OAKH_KEY); $OH->setOrigin($DATA['origin']['address1'],$DATA['origin']['city'],$DATA['origin']['province'],$DATA['origin']['postal_code'],$DATA['origin']['country']); $OH->setDestination($DATA['destination']['address1'],$DATA['destination']['city'],$DATA['destination']['province'],$DATA['destination']['postal_code'],$DATA['destination']['country']); $OH->setOptions($options); $r = $OH->getRate($packages,'IMPERIAL'); if ($r) { foreach ($r as $_r) { $_RATES[] = array( "service_name" => $_r['name'], "service_code" => $_r['code'], "total_price" => $_r['amount']*100, //in cents "currency" => $_r['currency'], ); } } return $_RATES; /* do not edit below this line */ }