本文整理汇总了PHP中Mage_Sales_Model_Order_Shipment::getAllTracks方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Order_Shipment::getAllTracks方法的具体用法?PHP Mage_Sales_Model_Order_Shipment::getAllTracks怎么用?PHP Mage_Sales_Model_Order_Shipment::getAllTracks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Order_Shipment
的用法示例。
在下文中一共展示了Mage_Sales_Model_Order_Shipment::getAllTracks方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateShipmentArray
public function generateShipmentArray(Mage_Sales_Model_Order_Shipment $shipment)
{
$address = $shipment->getShippingAddress();
$trackingMethods = $shipment->getAllTracks();
$primaryTrack = count($trackingMethods) ? $trackingMethods[0] : false;
$array = array('@context' => 'http://schema.org', '@type' => 'ParcelDelivery', 'deliveryAddress' => array('@type' => 'PostalAddress', 'streetAddress' => $address->getStreetFull(), 'addressLocality' => $address->getCity(), 'addressRegion' => $address->getRegionCode(), 'addressCountry' => $address->getCountry(), 'postalCode' => $address->getPostcode()), 'partOfOrder' => $this->generateOrderArray($shipment->getOrder()), "expectedArrivalUntil" => date("c", time() + 60 * 60 * 24 * 365.25));
if (count($trackingMethods)) {
$array['carrier'] = $primaryTrack->getTitle();
$array['trackingNumber'] = $primaryTrack->getNumber();
$array['trackingUrl'] = $this->helper('shipping')->getTrackingPopUpUrlByTrackId($primaryTrack->getId());
}
return $array;
}
示例2: _createShipmentInfo
protected function _createShipmentInfo(Mage_Sales_Model_Order_Shipment $shipment)
{
$result = array('shipmentId' => $shipment->getIncrementId(), 'shippingFees' => array('amount' => '0', 'code' => Mage::app()->getStore()->getBaseCurrencyCode()), 'discountAmount' => null, 'discounts' => null, 'additionalCost' => null, 'packagingHandlingCost' => null, 'surcharge' => null, 'trackingDetails' => $this->_createTrackingInfo($shipment->getAllTracks()), 'shippingMethod' => $shipment->getOrder()->getShippingDescription(), 'deliveryWindow' => null, 'shippingWindow' => null, 'shippingMessage' => null);
return $result;
}
示例3: confirmShipment
/**
* Confirm crating of shipment
*
* @param Mage_Sales_Model_Order_Shipment $shipment
* @return Mage_AmazonPayments_Model_Api_Cba
*/
public function confirmShipment($shipment)
{
$items = array();
foreach ($shipment->getAllItems() as $item) {
/* @var $item Mage_Sales_Model_Order_Shipment_Item */
if ($item->getOrderItem()->getParentItemId()) {
continue;
}
$items[] = array('id' => $item->getOrderItem()->getExtOrderItemId(), 'qty' => $item->getQty());
}
$carrierName = '';
$shippingMethod = '';
$trackNumber = '';
/**
* Magento track numbers is not connected with items.
* Get only first track number
*/
foreach ($shipment->getAllTracks() as $track) {
$carrierName = $track->getTitle();
$trackNumber = $track->getNumber();
break;
}
if (preg_match("/\\((.+)\\)/", $shipment->getOrder()->getShippingDescription(), $_result)) {
$shippingMethod = $_result[1];
}
$this->getDocumentApi()->confirmShipment($shipment->getOrder()->getExtOrderId(), $carrierName, $shippingMethod, $items, $trackNumber);
$shipment->addComment(Mage::helper('amazonpayments')->__('Shipment was created with Checkout by Amazon.'));
return $this;
}
示例4: sendShipment
/**
* Send order shipment to Rakuten Checkout
*
* @param Mage_Sales_Model_Order_Shipment $shipment
* @return bool
* @throws Exception|Mage_Core_Exception
*/
public function sendShipment($shipment)
{
// Create Rakuten Checkout Send Order Shipment XML request
$xml = new SimpleXMLElement("<?xml version='1.0' encoding='UTF-8' ?><tradoria_order_shipment />");
$merchantAuth = $xml->addChild('merchant_authentication');
$merchantAuth->addChild('project_id', $this->_projectId);
$merchantAuth->addChild('api_key', $this->_apiKey);
/** @var $order Mage_Sales_Model_Order */
$order = $shipment->getOrder();
$xml->addChild('order_no', $order->getExtOrderId());
$carrierTrackingId = $xml->addChild('carrier_tracking_id');
$carrierTrackingUrl = $xml->addChild('carrier_tracking_url');
$carrierTrackingCode = $xml->addChild('carrier_tracking_code');
if ($tracks = $shipment->getAllTracks()) {
/** @var $track Mage_Sales_Model_Order_Shipment_Track */
$track = array_shift($tracks);
// Multiple tracking codes for one shipment are supported by Magento
$this->_addCDATA($carrierTrackingId, $track->getCarrierCode());
$this->_addCDATA($carrierTrackingCode, $track->getNumber());
}
$request = $xml->asXML();
$response = $this->sendRequest($request, 'shipment');
try {
$response = new SimpleXMLElement($response);
if ($response->success != 'true') {
throw new Mage_Core_Exception((string) $response->message, (int) $response->code);
} else {
if ((string) $response->invoice_number != '') {
$comment = Mage::helper('rakuten')->__('Rakuten Invoice No: %s', '<strong>' . (string) $response->invoice_number . '</strong><br />');
$shipment->addComment($comment);
$order->addStatusHistoryComment($comment);
}
}
} catch (Mage_Core_Exception $e) {
throw $e;
} catch (Exception $e) {
Mage::logException($e);
throw $e;
}
return true;
}