/** * Creating a consignment note for the delivery * * @param Shippment $shippment The Shippment * @param string $manifestId The manifest id from the courier * * @throws Exception */ public function createConsignment(Shippment &$shippment, $manifestId = '') { list($apiUrl, $apiKey, $accId) = $this->_getAPIInfos(); $url = str_replace('{method}', 'fastlabel/addconsignment', trim($apiUrl)); $itemsString = array(); foreach ($shippment->getOrder()->getOrderItems() as $index => $item) { $itemString = array(); $itemString[] = "Items[{$index}].Reference=" . $shippment->getOrder()->getOrderNo(); $itemString[] = "Items[{$index}].Quantity=" . 1; $itemString[] = "Items[{$index}].Weight=" . 1; $itemString[] = "Items[{$index}].Packaging=" . 1; $itemString[] = "Items[{$index}].Length=" . ''; $itemString[] = "Items[{$index}].Width=" . ''; $itemString[] = "Items[{$index}].Height=" . ''; $itemsString[] = implode('&', $itemString); } $emails = $shippment->getOrder()->getInfo(OrderInfoType::ID_CUS_EMAIL); $params = array('api_key' => trim($apiKey), 'UserID' => trim($accId), 'ManifestID' => trim($manifestId), 'ContactName' => trim($shippment->getReceiver()), 'Address1' => trim($shippment->getOrder()->getShippingAddr()->getStreet()), 'Suburb' => trim($shippment->getOrder()->getShippingAddr()->getCity()), 'Postcode' => trim($shippment->getOrder()->getShippingAddr()->getPostCode()), 'ContactEmail' => count($emails) > 0 ? $emails[0] : '', 'ContactMobile' => trim($shippment->getContact()), 'SpecialInstruction1' => trim($shippment->getDeliveryInstructions())); $paramString = http_build_query($params) . '&' . implode('&', $itemsString); $result = $this->_getJsonResult(ComScriptCURL::readUrl($url . '?' . $paramString, ComScriptCURL::CURL_TIMEOUT)); return $result; }