本文整理汇总了PHP中Mage_Sales_Model_Order_Shipment类的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Order_Shipment类的具体用法?PHP Mage_Sales_Model_Order_Shipment怎么用?PHP Mage_Sales_Model_Order_Shipment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mage_Sales_Model_Order_Shipment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _addShipmentWithTrack
/**
* Adds shipment with specified tracking number
*
* @param Mage_Sales_Model_Order_Shipment $shipment
* @param Mage_Sales_Model_Order_Shipment_Track $track
*/
private function _addShipmentWithTrack(Mage_Sales_Model_Order_Shipment $shipment, Mage_Sales_Model_Order_Shipment_Track $track = null)
{
$mageCarrierCode = $this->_getCarrierCodeFromOrder($shipment->getOrder());
$carrierCode = $this->_getConfig()->getCarrierCode($mageCarrierCode);
$otherCarrierName = $carrierCode == Mage_GoogleTrustedStore_Model_Config::CARRIER_CODE_OTHER ? $this->_getConfig()->getOtherCarrierName($mageCarrierCode) : '';
$this->_addRow(array($shipment->getOrder()->getIncrementId(), trim($track ? $track->getNumber() : ''), $carrierCode, $otherCarrierName, $shipment->getCreatedAtDate()->toString('yyyy-MM-dd')));
}
示例2: processOrder
private function processOrder(Ess_M2ePro_Model_Order $order, Mage_Sales_Model_Order_Shipment $shipment, array $trackingDetails = array())
{
if ($order->isSingle() || !$order->isComponentModeEbay() || count($shipment->getAllItems()) != 1) {
return $order->getChildObject()->updateShippingStatus($trackingDetails);
}
// combined eBay orders only
$shipmentItems = $shipment->getAllItems();
$shipmentItem = reset($shipmentItems);
/** @var $shipmentItem Mage_Sales_Model_Order_Shipment_Item */
$additionalData = $shipmentItem->getOrderItem()->getAdditionalData();
$additionalData = is_string($additionalData) ? @unserialize($additionalData) : array();
if (empty($additionalData['ebay_item_id']) || empty($additionalData['ebay_transaction_id'])) {
return $order->getChildObject()->updateShippingStatus($trackingDetails);
}
$itemToShip = null;
foreach ($order->getItemsCollection()->getItems() as $item) {
/** @var $item Ess_M2ePro_Model_Order_Item */
if ($item->getChildObject()->getItemId() == $additionalData['ebay_item_id'] || $item->getChildObject()->getTransactionId() == $additionalData['ebay_transaction_id']) {
$itemToShip = $item;
break;
}
}
if (is_null($itemToShip)) {
return $order->getChildObject()->updateShippingStatus($trackingDetails);
}
$params = array();
if (count($trackingDetails) > 0) {
$params['tracking_number'] = $trackingDetails['tracking_number'];
$params['carrier_code'] = Mage::helper('M2ePro/Component_Ebay')->getCarrierTitle($trackingDetails['carrier_code'], $trackingDetails['carrier_title']);
}
/** @var $dispatcher Ess_M2ePro_Model_Connector_Server_Ebay_OrderItem_Dispatcher */
$dispatcher = Mage::getModel('M2ePro/Connector_Server_Ebay_OrderItem_Dispatcher');
$action = Ess_M2ePro_Model_Connector_Server_Ebay_OrderItem_Dispatcher::ACTION_UPDATE_STATUS;
return $dispatcher->process($action, $itemToShip, $params);
}
示例3: buildMap
/**
* @param Mage_Sales_Model_Order_Shipment $shipment
* @return array
*/
public function buildMap(Mage_Sales_Model_Order_Shipment $shipment)
{
$map = array('packingslip_id_label' => $this->getSalesHelper()->__('Packingslip # '), 'order_id_label' => $this->getSalesHelper()->__('Order # '), 'order_date_label' => $this->getSalesHelper()->__('Order Date: '), 'billing_address_label' => $this->getSalesHelper()->__('Sold to:'), 'shipping_address_label' => $this->getSalesHelper()->__('Ship to:'), 'payment_method_label' => $this->getSalesHelper()->__('Payment Method:'), 'shipping_method_label' => $this->getSalesHelper()->__('Shipping Method:'), 'products_qty_label' => $this->getSalesHelper()->__('Qty'), 'products_label' => $this->getSalesHelper()->__('Products'), 'products_sku_label' => $this->getSalesHelper()->__('SKU'));
$order = $shipment->getOrder();
$billingAddress = $order->getBillingAddress();
$map['packingslip_id'] = $shipment->getIncrementId();
$map['order_id'] = Mage::getStoreConfigFlag(Mage_Sales_Model_Order_Pdf_Shipment::XML_PATH_SALES_PDF_SHIPMENT_PUT_ORDER_ID, $order->getStoreId()) ? $order->getRealOrderId() : 'N/A';
$map['order_date'] = $this->getCoreHelper()->formatDate($order->getCreatedAtStoreDate(), 'medium', false);
$map['billing_name'] = $billingAddress->getFirstname() . ' ' . $billingAddress->getLastname();
$map['billing_street'] = $billingAddress->getStreetFull();
$map['billing_city'] = $billingAddress->getCity();
$map['billing_zip'] = $billingAddress->getPostcode();
$map['billing_country'] = $billingAddress->getCountryModel()->getIso2Code();
$map['billing_phone'] = $billingAddress->getTelephone();
$shippingAddress = $order->getShippingAddress();
$map['shipping_name'] = $shippingAddress->getFirstname() . ' ' . $shippingAddress->getLastname();
$map['shipping_street'] = $shippingAddress->getStreetFull();
$map['shipping_city'] = $shippingAddress->getCity();
$map['shipping_zip'] = $shippingAddress->getPostcode();
$map['shipping_country'] = $shippingAddress->getCountry();
$map['shipping_phone'] = $shippingAddress->getTelephone();
$map['payment_method'] = $paymentInfo = $this->getPaymentHelper()->getInfoBlock($order->getPayment())->setIsSecureMode(true)->toHtml();
$map['shipping_method'] = $order->getShippingDescription();
$map['shipping_charges'] = '(' . $this->getSalesHelper()->__('Total Shipping Charges') . ' ' . $order->formatPriceTxt($order->getShippingAmount()) . ')';
$map['products_data'] = '';
foreach ($shipment->getAllItems() as $item) {
if ($item->getOrderItem()->getParentItem()) {
continue;
}
$map['products_data'] .= $this->drawItem($item, $order);
}
return $map;
}
示例4: _getTrackingUrl
/**
* Retrieve tracking url with params
*
* @param string $key
* @param Mage_Sales_Model_Order|Mage_Sales_Model_Order_Shipment|Mage_Sales_Model_Order_Shipment_Track $model
* @param string $method Optional - method of a model to get id
* @return string
*/
protected function _getTrackingUrl($key, $model, $method = 'getId')
{
$helper = Mage::helper('Mage_Core_Helper_Data');
$urlPart = "{$key}:{$model->{$method}()}:{$model->getProtectCode()}";
$param = array('hash' => $helper->urlEncode($urlPart));
$storeModel = Mage::app()->getStore($model->getStoreId());
return $storeModel->getUrl('shipping/tracking/popup', $param);
}
示例5: mustShipInOneParcel
/**
* True is returned if we transport the shipment in a single package.
*
* @param Mage_Sales_Model_Order_Shipment $shipment
*
* @return boolean
*/
public function mustShipInOneParcel(Mage_Sales_Model_Order_Shipment $shipment)
{
$carrier = $shipment->getOrder()->getShippingCarrier();
if ($carrier instanceof Zitec_PackedShipment_Model_Carrier_Interface) {
$shippingMethod = $shipment->getOrder()->getShippingMethod();
return $carrier->shippingMethodRequiresShipmentsOfOnlyOneParcel($shippingMethod);
}
return true;
}
示例6: getItemsToShip
private function getItemsToShip(Ess_M2ePro_Model_Order $order, Mage_Sales_Model_Order_Shipment $shipment)
{
$productTypesNotAllowedByDefault = array(Mage_Catalog_Model_Product_Type::TYPE_BUNDLE, Mage_Catalog_Model_Product_Type::TYPE_GROUPED);
$items = array();
$allowedItems = array();
foreach ($shipment->getAllItems() as $shipmentItem) {
/** @var $shipmentItem Mage_Sales_Model_Order_Shipment_Item */
$orderItem = $shipmentItem->getOrderItem();
$parentOrderItemId = $orderItem->getParentItemId();
if (!is_null($parentOrderItemId)) {
!in_array($parentOrderItemId, $allowedItems) && ($allowedItems[] = $parentOrderItemId);
continue;
}
if (!in_array($orderItem->getProductType(), $productTypesNotAllowedByDefault)) {
$allowedItems[] = $orderItem->getId();
}
$additionalData = $orderItem->getAdditionalData();
$additionalData = is_string($additionalData) ? @unserialize($additionalData) : array();
$itemId = $transactionId = null;
$orderItemDataIdentifier = Ess_M2ePro_Helper_Data::CUSTOM_IDENTIFIER;
if (isset($additionalData['ebay_item_id']) && isset($additionalData['ebay_transaction_id'])) {
// backward compatibility with versions 5.0.4 or less
$itemId = $additionalData['ebay_item_id'];
$transactionId = $additionalData['ebay_transaction_id'];
} elseif (isset($additionalData[$orderItemDataIdentifier]['items'])) {
if (!is_array($additionalData[$orderItemDataIdentifier]['items']) || count($additionalData[$orderItemDataIdentifier]['items']) != 1) {
return null;
}
if (isset($additionalData[$orderItemDataIdentifier]['items'][0]['item_id'])) {
$itemId = $additionalData[$orderItemDataIdentifier]['items'][0]['item_id'];
}
if (isset($additionalData[$orderItemDataIdentifier]['items'][0]['transaction_id'])) {
$transactionId = $additionalData[$orderItemDataIdentifier]['items'][0]['transaction_id'];
}
}
if (is_null($itemId) || is_null($transactionId)) {
continue;
}
$item = Mage::helper('M2ePro/Component_Ebay')->getCollection('Order_Item')->addFieldToFilter('order_id', $order->getId())->addFieldToFilter('item_id', $itemId)->addFieldToFilter('transaction_id', $transactionId)->getFirstItem();
if (!$item->getId()) {
continue;
}
$items[$orderItem->getId()] = $item;
}
$resultItems = array();
foreach ($items as $orderItemId => $item) {
if (!in_array($orderItemId, $allowedItems)) {
continue;
}
$resultItems[] = $item;
}
return $resultItems;
}
示例7: 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;
}
示例8: getTrackingDetails
protected function getTrackingDetails(Mage_Sales_Model_Order_Shipment $shipment)
{
$track = $shipment->getTracksCollection()->getLastItem();
$trackingDetails = array();
if ($track->getData('number') != '') {
$carrierCode = trim($track->getData('carrier_code'));
if (strtolower($carrierCode) == 'dhlint') {
$carrierCode = 'dhl';
}
$trackingDetails = array('carrier_title' => trim($track->getData('title')), 'carrier_code' => $carrierCode, 'tracking_number' => (string) $track->getData('number'));
}
return $trackingDetails;
}
示例9: saveShipment
/**
* Save shipment
*
* @param Mage_Sales_Model_Order_Shipment $shipment
* @param array $data
* @return bool
*/
public function saveShipment($shipment, $data)
{
$result = false;
$carrierCode = $shipment->getOrder()->getShippingCarrier()->getCarrierCode();
switch (true) {
case Mage::getModel('shippingcore/carrier_aramex')->isUsed($carrierCode):
$result = Mage::getModel('shippingcore/carrier_aramex')->saveShipment($shipment, $data);
break;
case Mage::getModel('shippingcore/carrier_skynet')->isUsed($carrierCode):
$result = Mage::getModel('shippingcore/carrier_skynet')->saveShipment($shipment, $data);
break;
}
return $result;
}
示例10: testSendEmail
/**
* @magentoConfigFixture current_store design/theme/full_name default/default/default
* @magentoDataFixture Mage/Sales/_files/order.php
*/
public function testSendEmail()
{
$order = new Mage_Sales_Model_Order();
$order->loadByIncrementId('100000001');
$order->setCustomerEmail('customer@example.com');
$shipment = new Mage_Sales_Model_Order_Shipment();
$shipment->setOrder($order);
$payment = $order->getPayment();
$paymentInfoBlock = Mage::helper('Mage_Payment_Helper_Data')->getInfoBlock($payment);
$paymentInfoBlock->setArea('invalid-area');
$payment->setBlockMock($paymentInfoBlock);
$this->assertEmpty($shipment->getEmailSent());
$shipment->sendEmail(true);
$this->assertNotEmpty($shipment->getEmailSent());
$this->assertEquals('frontend', $paymentInfoBlock->getArea());
}
示例11: getItemsToShip
/**
* @param Ess_M2ePro_Model_Order $order
* @param Mage_Sales_Model_Order_Shipment $shipment
*
* @return Ess_M2ePro_Model_Order_Item[]
*/
private function getItemsToShip(Ess_M2ePro_Model_Order $order, Mage_Sales_Model_Order_Shipment $shipment)
{
$shipmentItems = $shipment->getAllItems();
$orderItemDataIdentifier = Ess_M2ePro_Helper_Data::CUSTOM_IDENTIFIER;
$items = array();
foreach ($shipmentItems as $shipmentItem) {
$additionalData = $shipmentItem->getOrderItem()->getAdditionalData();
$additionalData = is_string($additionalData) ? @unserialize($additionalData) : array();
if (!isset($additionalData[$orderItemDataIdentifier]['items'][0]['order_item_id'])) {
continue;
}
$id = $additionalData[$orderItemDataIdentifier]['items'][0]['order_item_id'];
$item = $order->getItemsCollection()->getItemByColumnValue('play_order_item_id', $id);
if (is_null($item)) {
continue;
}
$items[] = $item;
}
return $items;
}
示例12: getItemToShip
/**
* @param Ess_M2ePro_Model_Order $order
* @param Mage_Sales_Model_Order_Shipment $shipment
*
* @return null|Ess_M2ePro_Model_Order_Item
*/
private function getItemToShip(Ess_M2ePro_Model_Order $order, Mage_Sales_Model_Order_Shipment $shipment)
{
if ($order->isSingle()) {
return null;
}
$shipmentItems = $shipment->getAllItems();
if (count($shipmentItems) != 1) {
return null;
}
/** @var $shipmentItem Mage_Sales_Model_Order_Shipment_Item */
$shipmentItem = reset($shipmentItems);
$additionalData = $shipmentItem->getOrderItem()->getAdditionalData();
$additionalData = is_string($additionalData) ? @unserialize($additionalData) : array();
$itemId = $transactionId = null;
$orderItemDataIdentifier = Ess_M2ePro_Helper_Data::CUSTOM_IDENTIFIER;
if (isset($additionalData['ebay_item_id']) && isset($additionalData['ebay_transaction_id'])) {
// backward compatibility with versions 5.0.4 or less
$itemId = $additionalData['ebay_item_id'];
$transactionId = $additionalData['ebay_transaction_id'];
} elseif (isset($additionalData[$orderItemDataIdentifier]['items'])) {
if (!is_array($additionalData[$orderItemDataIdentifier]['items']) || count($additionalData[$orderItemDataIdentifier]['items']) != 1) {
return null;
}
if (isset($additionalData[$orderItemDataIdentifier]['items'][0]['item_id'])) {
$itemId = $additionalData[$orderItemDataIdentifier]['items'][0]['item_id'];
}
if (isset($additionalData[$orderItemDataIdentifier]['items'][0]['transaction_id'])) {
$transactionId = $additionalData[$orderItemDataIdentifier]['items'][0]['transaction_id'];
}
}
if (is_null($itemId) || is_null($transactionId)) {
return null;
}
$item = Mage::helper('M2ePro/Component_Ebay')->getCollection('Order_Item')->addFieldToFilter('order_id', $order->getId())->addFieldToFilter('item_id', $itemId)->addFieldToFilter('transaction_id', $transactionId)->getFirstItem();
return $item->getId() ? $item : null;
}
示例13: getItemsToShip
/**
* @param Ess_M2ePro_Model_Order $order
* @param Mage_Sales_Model_Order_Shipment $shipment
*
* @throws LogicException
*
* @return array
*/
private function getItemsToShip(Ess_M2ePro_Model_Order $order, Mage_Sales_Model_Order_Shipment $shipment)
{
$shipmentItems = $shipment->getAllItems();
$orderItemDataIdentifier = Ess_M2ePro_Helper_Data::CUSTOM_IDENTIFIER;
$items = array();
foreach ($shipmentItems as $shipmentItem) {
$additionalData = $shipmentItem->getOrderItem()->getAdditionalData();
$additionalData = is_string($additionalData) ? @unserialize($additionalData) : array();
if (!isset($additionalData[$orderItemDataIdentifier]['items'])) {
continue;
}
if (!is_array($additionalData[$orderItemDataIdentifier]['items'])) {
continue;
}
$qtyAvailable = (int) $shipmentItem->getQty();
foreach ($additionalData[$orderItemDataIdentifier]['items'] as $data) {
if ($qtyAvailable <= 0) {
continue;
}
if (!isset($data['order_item_id'])) {
continue;
}
$item = $order->getItemsCollection()->getItemByColumnValue('amazon_order_item_id', $data['order_item_id']);
if (is_null($item)) {
continue;
}
$qty = $item->getChildObject()->getQtyPurchased();
if ($qty > $qtyAvailable) {
$qty = $qtyAvailable;
}
$items[] = array('qty' => $qty, 'amazon_order_item_id' => $data['order_item_id']);
$qtyAvailable -= $qty;
}
}
return $items;
}
示例14: _saveShipment
/**
* Saving shipment and order in one transaction.
* @param Mage_Sales_Model_Order_Shipment $shipment
* @param string $incrementId
* @return self
*/
protected function _saveShipment(Mage_Sales_Model_Order_Shipment $shipment, $incrementId)
{
$order = $shipment->getOrder();
$order->setIsInProcess(true);
$transactionSave = Mage::getModel('core/resource_transaction')->addObject($shipment)->addObject($order);
try {
$transactionSave->save();
} catch (Exception $e) {
$logData = ['increment_id' => $incrementId];
$logMessage = 'An error occurred saving shipment confirmation to order id ({increment_id}). See exception log for details.';
$this->_logger->error($logMessage, $this->_context->getMetaData(__CLASS__, $logData));
$this->_logger->logException($e, $this->_context->getMetaData(__CLASS__, [], $e));
}
return $this;
}
示例15: requestToShipment
/**
* Prepare and do request to shipment
*
* @param Mage_Sales_Model_Order_Shipment $orderShipment
* @return Varien_Object
*/
public function requestToShipment(Mage_Sales_Model_Order_Shipment $orderShipment)
{
$admin = Mage::getSingleton('admin/session')->getUser();
$order = $orderShipment->getOrder();
$address = $order->getShippingAddress();
$selectedShipMethod = $this->_mapShipMethod($order->getShippingMethod(true), $order->getShippingCarrier(), $address);
$shipmentStoreId = $orderShipment->getStoreId();
$shipmentCarrier = Mage::getModel('wsaendicia/carrier_endicia');
$shippingMethod = $this->_getShipmentCarrier($selectedShipMethod, $shipmentCarrier->getCarrierCode());
$baseCurrencyCode = Mage::app()->getStore($shipmentStoreId)->getBaseCurrencyCode();
if (!$shipmentCarrier) {
Mage::throwException('Invalid carrier: ' . $shippingMethod->getCarrierCode());
}
$shipperRegionCode = Mage::getStoreConfig(self::XML_PATH_STORE_REGION_ID, $shipmentStoreId);
if (is_numeric($shipperRegionCode)) {
$shipperRegionCode = Mage::getModel('directory/region')->load($shipperRegionCode)->getCode();
}
$recipientRegionCode = Mage::getModel('directory/region')->load($address->getRegionId())->getCode();
$originStreet1 = Mage::getStoreConfig(self::XML_PATH_STORE_ADDRESS1, $shipmentStoreId);
$originStreet2 = Mage::getStoreConfig(self::XML_PATH_STORE_ADDRESS2, $shipmentStoreId);
$storeInfo = new Varien_Object(Mage::getStoreConfig('general/store_information', $shipmentStoreId));
if (!$admin->getFirstname() || !$admin->getLastname() || !$storeInfo->getName() || !$storeInfo->getPhone() || !$originStreet1 || !Mage::getStoreConfig(self::XML_PATH_STORE_CITY, $shipmentStoreId) || !$shipperRegionCode || !Mage::getStoreConfig(self::XML_PATH_STORE_ZIP, $shipmentStoreId) || !Mage::getStoreConfig(self::XML_PATH_STORE_COUNTRY_ID, $shipmentStoreId)) {
Mage::throwException(Mage::helper('sales')->__('Insufficient information to create shipping label(s). Please verify your Store Information and Shipping Settings.'));
}
/** @var $request Mage_Shipping_Model_Shipment_Request */
$request = Mage::getModel('shipping/shipment_request');
$request->setOrderShipment($orderShipment);
$request->setShipperContactPersonName($admin->getName());
$request->setShipperContactPersonFirstName($admin->getFirstname());
$request->setShipperContactPersonLastName($admin->getLastname());
$request->setShipperContactCompanyName($storeInfo->getName());
$request->setShipperContactPhoneNumber($storeInfo->getPhone());
$request->setShipperEmail($admin->getEmail());
$request->setShipperAddressStreet(trim($originStreet1 . ' ' . $originStreet2));
$request->setShipperAddressStreet1($originStreet1);
$request->setShipperAddressStreet2($originStreet2);
$request->setShipperAddressCity(Mage::getStoreConfig(self::XML_PATH_STORE_CITY, $shipmentStoreId));
$request->setShipperAddressStateOrProvinceCode($shipperRegionCode);
$request->setShipperAddressPostalCode(Mage::getStoreConfig(self::XML_PATH_STORE_ZIP, $shipmentStoreId));
$request->setShipperAddressCountryCode(Mage::getStoreConfig(self::XML_PATH_STORE_COUNTRY_ID, $shipmentStoreId));
$request->setRecipientContactPersonName(trim($address->getFirstname() . ' ' . $address->getLastname()));
$request->setRecipientContactPersonFirstName($address->getFirstname());
$request->setRecipientContactPersonLastName($address->getLastname());
$request->setRecipientContactCompanyName($address->getCompany());
$request->setRecipientContactPhoneNumber($address->getTelephone());
$request->setRecipientEmail($address->getEmail());
$request->setRecipientAddressStreet(trim($address->getStreet1() . ' ' . $address->getStreet2()));
$request->setRecipientAddressStreet1($address->getStreet1());
$request->setRecipientAddressStreet2($address->getStreet2());
$request->setRecipientAddressCity($address->getCity());
$request->setRecipientAddressStateOrProvinceCode($address->getRegionCode());
$request->setRecipientAddressRegionCode($recipientRegionCode);
$request->setRecipientAddressPostalCode($address->getPostcode());
$request->setRecipientAddressCountryCode($address->getCountryId());
$request->setShippingMethod($shippingMethod->getMethod());
$request->setPackageWeight($order->getWeight());
$request->setPackages($orderShipment->getPackages());
$request->setBaseCurrencyCode($baseCurrencyCode);
$request->setStoreId($shipmentStoreId);
return $shipmentCarrier->requestToShipment($request);
}