当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Sales_Model_Order::canShip方法代码示例

本文整理汇总了PHP中Mage_Sales_Model_Order::canShip方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Order::canShip方法的具体用法?PHP Mage_Sales_Model_Order::canShip怎么用?PHP Mage_Sales_Model_Order::canShip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage_Sales_Model_Order的用法示例。


在下文中一共展示了Mage_Sales_Model_Order::canShip方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: canMakePayment

 /**
  * Check if can make payment for order
  *
  * @param Mage_Sales_Model_Order $order
  * @return bool
  */
 public function canMakePayment($order)
 {
     if ($order->getPayment() && $order->getPayment()->getMethod() == 'purchaseorder' && $order->canShip()) {
         return false;
     }
     if ($order->getStatus() != 'purchaseorder_pending_payment') {
         return false;
     }
     if (!$order->canInvoice()) {
         return false;
     }
     return true;
 }
开发者ID:flintdigital,项目名称:mage-mod-ar-po-emja,代码行数:19,代码来源:Data.php

示例2: _createTracking

 /**
  * Create new shipment for order
  * Inspired by Mage_Sales_Model_Order_Shipment_Api methods
  *
  * @param Mage_Sales_Model_Order $order (it should exist, no control is done into the method)
  * @param string $trackingNumber
  * @param string $trackingTitle
  * @param booleam $email
  * @param string $comment
  * @param boolean $includeComment
  * @return int : shipment real id if creation was ok, else 0
  */
 public function _createTracking($order, $trackingNumber, $trackingTitle, $email, $comment, $includeComment)
 {
     /**
      * Check shipment creation availability
      */
     if (!$order->canShip()) {
         $this->_getSession()->addError($this->__('La commande %s ne peut pas être expédiée, ou a déjà été expédiée.', $order->getRealOrderId()));
         return 0;
     }
     /**
      * Initialize the Mage_Sales_Model_Order_Shipment object
      */
     $convertor = Mage::getModel('sales/convert_order');
     $shipment = $convertor->toShipment($order);
     /**
      * Add the items to send
      */
     foreach ($order->getAllItems() as $orderItem) {
         if (!$orderItem->getQtyToShip()) {
             continue;
         }
         if ($orderItem->getIsVirtual()) {
             continue;
         }
         $item = $convertor->itemToShipmentItem($orderItem);
         $qty = $orderItem->getQtyToShip();
         $item->setQty($qty);
         $shipment->addItem($item);
     }
     //foreach
     $shipment->register();
     /**
      * Tracking number instanciation
      */
     $carrierCode = stristr($order->getShippingMethod(), '_', true);
     if (!$carrierCode) {
         $carrierCode = 'custom';
     }
     /* depot code and shipper code determination */
     switch ($carrierCode) {
         case 'dpdfrrelais':
             $depot_code = Mage::getStoreConfig('carriers/dpdfrrelais/depot');
             $shipper_code = Mage::getStoreConfig('carriers/dpdfrrelais/cargo');
             break;
         case 'dpdfrpredict':
             $depot_code = Mage::getStoreConfig('carriers/dpdfrpredict/depot');
             $shipper_code = Mage::getStoreConfig('carriers/dpdfrpredict/cargo');
             break;
         case 'dpdfrclassic':
             $depot_code = Mage::getStoreConfig('carriers/dpdfrclassic/depot');
             $shipper_code = Mage::getStoreConfig('carriers/dpdfrclassic/cargo');
             break;
     }
     // Le trackingNumber est composé du n° de commande + le code agence + code cargo, intégré en un bloc dans l'URL
     $trackingNumber = $order->getIncrementID() . '_' . $depot_code . $shipper_code;
     $trackingUrl = 'http://www.dpd.fr/tracer_' . $trackingNumber;
     $track = Mage::getModel('sales/order_shipment_track')->setNumber($trackingNumber)->setCarrierCode($carrierCode)->setTitle($trackingTitle)->setUrl($trackingUrl)->setStatus('<a target="_blank" href="' . $trackingUrl . '">' . __('Suivre ce colis DPD France') . '</a>');
     $shipment->addTrack($track);
     /**
      * Comment handling
      */
     $shipment->addComment($comment, $email && $includeComment);
     /**
      * Change order status to Processing
      */
     $shipment->getOrder()->setIsInProcess(true);
     /**
      * If e-mail, set as sent (must be done before shipment object saving)
      */
     if ($email) {
         $shipment->setEmailSent(true);
     }
     try {
         // /**
         // * Save the created shipment and the updated order
         // */
         $shipment->save();
         $shipment->getOrder()->save();
         // /**
         // * Email sending
         // */
         $shipment->sendEmail($email, $includeComment ? $comment : '');
     } catch (Mage_Core_Exception $e) {
         $this->_getSession()->addError($this->__('Erreur pendant la création de l\'expédition %s : %s', $orderId, $e->getMessage()));
         return 0;
     }
     /**
      * Everything was ok : return Shipment real id
//.........这里部分代码省略.........
开发者ID:purpleweb,项目名称:DPDFrance_Magento1.4-1.9,代码行数:101,代码来源:TrackingController.php

示例3: checkOrder

 /**
  * Check order
  *
  * @throws Dhl_Intraship_Model_Autocreate_Exception
  * @param  Mage_Sales_Model_Order                   $order
  * @return Dhl_Intraship_Model_Autocreate           $this
  */
 public function checkOrder(Mage_Sales_Model_Order $order)
 {
     // Check order existing.
     if (!$order->getId()) {
         throw new Dhl_Intraship_Model_Autocreate_Exception('The order no longer exists.');
     }
     // Check shipment is available to create separate from invoice.
     if ($order->getForcedDoShipmentWithInvoice()) {
         throw new Dhl_Intraship_Model_Autocreate_Exception('Cannot do shipment for the order separately from invoice.');
     }
     // Check shipment create availability.
     if (!$order->canShip()) {
         throw new Dhl_Intraship_Model_Autocreate_Exception('Cannot do shipment for the order.');
     }
     return $this;
 }
开发者ID:igorvasiliev4,项目名称:magento_code,代码行数:23,代码来源:Autocreate.php

示例4: _createShipment

 /**
  * Create new shipment for order
  * Inspired by Mage_Sales_Model_Order_Shipment_Api methods
  *
  * @param Mage_Sales_Model_Order $order (it should exist, no control is done into the method)
  * @param string $trackingNumber
  * @param string $trackingTitle
  * @param booleam $email
  * @param string $comment
  * @param boolean $includeComment
  * @return int : shipment real id if creation was ok, else 0
  */
 public function _createShipment($order, $invoice, $trackingNumber, $trackingTitle, $email, $comment, $includeComment)
 {
     /**
      * Check shipment creation availability
      */
     if (!$order->canShip()) {
         $this->_getSession()->addError($this->__('Order %s - Invoice %s can not be shipped or has already been shipped, tracking number %s', $order->getIncrementId(), $invoice->getIncrementId(), $trackingNumber));
         return 0;
     }
     /**
      * Initialize the Mage_Sales_Model_Order_Shipment object
      */
     $convertor = Mage::getModel('sales/convert_order');
     $shipment = $convertor->toShipment($order);
     /**
      * Add the items to send
      */
     foreach ($order->getAllItems() as $orderItem) {
         if (!$orderItem->getQtyToShip()) {
             continue;
         }
         if ($orderItem->getIsVirtual()) {
             continue;
         }
         $item = $convertor->itemToShipmentItem($orderItem);
         $qty = $orderItem->getQtyToShip();
         $item->setQty($qty);
         $shipment->addItem($item);
     }
     //foreach
     $shipment->register();
     /**
      * Tracking number instanciation
      */
     $track = Mage::getModel('sales/order_shipment_track')->setNumber($trackingNumber)->setCarrierCode('custom')->setTitle($trackingTitle);
     $shipment->addTrack($track);
     /**
      * Comment handling
      */
     $shipment->addComment($comment, $email && $includeComment);
     /**
      * Change order status to Processing
      */
     //$shipment->getOrder()->setIsInProcess(true);
     /**
      * Change order status to Processing shipped
      */
     $shipment->getOrder()->setState('processing', 'processing_shipped', $this->__('Tracking Number') . ': ' . $trackingNumber, True);
     /**
      * If e-mail, set as sent (must be done before shipment object saving)
      */
     if ($email) {
         $shipment->setEmailSent(true);
     }
     try {
         /**
          * Save the created shipment and the updated order
          */
         $shipment->save();
         $shipment->getOrder()->save();
         /**
          * Email sending
          */
         $shipment->sendEmail($email, $includeComment ? $comment : '');
     } catch (Mage_Core_Exception $e) {
         $this->_getSession()->addError($this->__('Shipment creation error for Order %s : %s', $orderId, $e->getMessage()));
         return 0;
     }
     $this->_getSession()->addSuccess($this->__('Tracking number %s was successfully added to order %s', $trackingNumber, $order->getIncrementId()));
     /**
      * Everything was ok : return Shipment real id
      */
     return $shipment->getIncrementId();
 }
开发者ID:Zerocard,项目名称:free-magento-extensions,代码行数:86,代码来源:ImportController.php

示例5: CreateMagentoShopRequestOrder

 function CreateMagentoShopRequestOrder(Mage_Sales_Model_Order $order, $paymentmethod)
 {
     $request = new Byjuno_Cdp_Helper_Api_Classes_ByjunoRequest();
     $request->setClientId(Mage::getStoreConfig('payment/cdp/clientid', Mage::app()->getStore()));
     $request->setUserID(Mage::getStoreConfig('payment/cdp/userid', Mage::app()->getStore()));
     $request->setPassword(Mage::getStoreConfig('payment/cdp/password', Mage::app()->getStore()));
     $request->setVersion("1.00");
     try {
         $request->setRequestEmail(Mage::getStoreConfig('payment/cdp/mail', Mage::app()->getStore()));
     } catch (Exception $e) {
     }
     $b = $order->getCustomerDob();
     if (!empty($b)) {
         $request->setDateOfBirth(Mage::getModel('core/date')->date('Y-m-d', strtotime($b)));
     }
     $g = $order->getCustomerGender();
     if (!empty($g)) {
         if ($g == '1') {
             $request->setGender('1');
         } else {
             if ($g == '2') {
                 $request->setGender('2');
             }
         }
     }
     $requestId = uniqid((string) $order->getBillingAddress()->getId() . "_");
     $request->setRequestId($requestId);
     $reference = $order->getCustomerId();
     if (empty($reference)) {
         $request->setCustomerReference("guest_" . $order->getBillingAddress()->getId());
     } else {
         $request->setCustomerReference($order->getCustomerId());
     }
     $request->setFirstName((string) $order->getBillingAddress()->getFirstname());
     $request->setLastName((string) $order->getBillingAddress()->getLastname());
     $request->setFirstLine(trim((string) $order->getBillingAddress()->getStreetFull()));
     $request->setCountryCode(strtoupper((string) $order->getBillingAddress()->getCountry()));
     $request->setPostCode((string) $order->getBillingAddress()->getPostcode());
     $request->setTown((string) $order->getBillingAddress()->getCity());
     $request->setFax((string) trim($order->getBillingAddress()->getFax(), '-'));
     $request->setLanguage((string) substr(Mage::app()->getLocale()->getLocaleCode(), 0, 2));
     if ($order->getBillingAddress()->getCompany()) {
         $request->setCompanyName1($order->getBillingAddress()->getCompany());
     }
     $request->setTelephonePrivate((string) trim($order->getBillingAddress()->getTelephone(), '-'));
     $request->setEmail((string) $order->getBillingAddress()->getEmail());
     $extraInfo["Name"] = 'ORDERCLOSED';
     $extraInfo["Value"] = 'NO';
     $request->setExtraInfo($extraInfo);
     $extraInfo["Name"] = 'ORDERAMOUNT';
     $extraInfo["Value"] = number_format($order->getGrandTotal(), 2, '.', '');
     $request->setExtraInfo($extraInfo);
     $extraInfo["Name"] = 'ORDERCURRENCY';
     $extraInfo["Value"] = $order->getBaseCurrencyCode();
     $request->setExtraInfo($extraInfo);
     /* shipping information */
     if ($order->canShip()) {
         $extraInfo["Name"] = 'DELIVERY_FIRSTNAME';
         $extraInfo["Value"] = $order->getShippingAddress()->getFirstname();
         $request->setExtraInfo($extraInfo);
         $extraInfo["Name"] = 'DELIVERY_LASTNAME';
         $extraInfo["Value"] = $order->getShippingAddress()->getLastname();
         $request->setExtraInfo($extraInfo);
         $extraInfo["Name"] = 'DELIVERY_FIRSTLINE';
         $extraInfo["Value"] = trim($order->getShippingAddress()->getStreetFull());
         $request->setExtraInfo($extraInfo);
         $extraInfo["Name"] = 'DELIVERY_HOUSENUMBER';
         $extraInfo["Value"] = '';
         $request->setExtraInfo($extraInfo);
         $extraInfo["Name"] = 'DELIVERY_COUNTRYCODE';
         $extraInfo["Value"] = strtoupper($order->getShippingAddress()->getCountry());
         $request->setExtraInfo($extraInfo);
         $extraInfo["Name"] = 'DELIVERY_POSTCODE';
         $extraInfo["Value"] = $order->getShippingAddress()->getPostcode();
         $request->setExtraInfo($extraInfo);
         $extraInfo["Name"] = 'DELIVERY_TOWN';
         $extraInfo["Value"] = $order->getShippingAddress()->getCity();
         $request->setExtraInfo($extraInfo);
         if ($order->getShippingAddress()->getCompany() != '' && Mage::getStoreConfig('payment/api/businesstobusiness', Mage::app()->getStore()) == 'enable') {
             $extraInfo["Name"] = 'DELIVERY_COMPANYNAME';
             $extraInfo["Value"] = $order->getShippingAddress()->getCompany();
             $request->setExtraInfo($extraInfo);
         }
     }
     $extraInfo["Name"] = 'PP_TRANSACTION_NUMBER';
     $extraInfo["Value"] = $requestId;
     $request->setExtraInfo($extraInfo);
     $extraInfo["Name"] = 'ORDERID';
     $extraInfo["Value"] = $order->getIncrementId();
     $request->setExtraInfo($extraInfo);
     $extraInfo["Name"] = 'PAYMENTMETHOD';
     $extraInfo["Value"] = 'BYJUNO-INVOICE';
     $request->setExtraInfo($extraInfo);
     $extraInfo["Name"] = 'CONNECTIVTY_MODULE';
     $extraInfo["Value"] = 'Byjuno Magento module 1.0.0';
     $request->setExtraInfo($extraInfo);
     return $request;
 }
开发者ID:istgin,项目名称:Byjuno,代码行数:98,代码来源:Data.php


注:本文中的Mage_Sales_Model_Order::canShip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。