當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Order::canShip方法代碼示例

本文整理匯總了PHP中Magento\Sales\Model\Order::canShip方法的典型用法代碼示例。如果您正苦於以下問題:PHP Order::canShip方法的具體用法?PHP Order::canShip怎麽用?PHP Order::canShip使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Sales\Model\Order的用法示例。


在下文中一共展示了Order::canShip方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: check

 /**
  * Check order status before save
  *
  * @param Order $order
  * @return $this
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function check(Order $order)
 {
     if (!$order->getId()) {
         return $order;
     }
     if (!$order->isCanceled() && !$order->canUnhold() && !$order->canInvoice() && !$order->canShip()) {
         if (0 == $order->getBaseGrandTotal() || $order->canCreditmemo()) {
             if ($order->getState() !== Order::STATE_COMPLETE) {
                 $order->setState(Order::STATE_COMPLETE)->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_COMPLETE));
             }
         } elseif (floatval($order->getTotalRefunded()) || !$order->getTotalRefunded() && $order->hasForcedCanCreditmemo()) {
             if ($order->getState() !== Order::STATE_CLOSED) {
                 $order->setState(Order::STATE_CLOSED)->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_CLOSED));
             }
         }
     }
     if ($order->getState() == Order::STATE_NEW && $order->getIsInProcess()) {
         $order->setState(Order::STATE_PROCESSING)->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_PROCESSING));
     }
     return $this;
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:29,代碼來源:State.php

示例2: _createShipment

 /**
  *
  */
 protected function _createShipment()
 {
     $this->_debugData['_createShipment'] = 'Creating shipment for order';
     // create shipment for cash payment
     $payment = $this->_order->getPayment()->getMethodInstance();
     if ($this->_order->canShip()) {
         $itemQty = array();
         $shipment = $this->_order->prepareShipment($itemQty);
         if ($shipment) {
             $shipment->register();
             $shipment->getOrder()->setIsInProcess(true);
             $comment = __('Shipment created by Adyen');
             $shipment->addComment($comment);
             /** @var \Magento\Framework\DB\Transaction $transaction */
             $transaction = $this->_transactionFactory->create();
             $transaction->addObject($shipment)->addObject($shipment->getOrder())->save();
             $this->_debugData['_createShipment done'] = 'Order is shipped';
         }
     } else {
         $this->_debugData['_createShipment error'] = 'Order can\'t be shipped';
     }
 }
開發者ID:pivulic,項目名稱:adyen-magento2,代碼行數:25,代碼來源:Cron.php

示例3: _createShipment

 /**
  * Create shipment
  *
  * @throws bool
  */
 protected function _createShipment()
 {
     $this->_adyenLogger->addAdyenNotificationCronjob('Creating shipment for order');
     // create shipment for cash payment
     $payment = $this->_order->getPayment()->getMethodInstance();
     if ($this->_order->canShip()) {
         $itemQty = [];
         $shipment = $this->_order->prepareShipment($itemQty);
         if ($shipment) {
             $shipment->register();
             $shipment->getOrder()->setIsInProcess(true);
             $comment = __('Shipment created by Adyen');
             $shipment->addComment($comment);
             /** @var \Magento\Framework\DB\Transaction $transaction */
             $transaction = $this->_transactionFactory->create();
             $transaction->addObject($shipment)->addObject($shipment->getOrder())->save();
             $this->_adyenLogger->addAdyenNotificationCronjob('Order is shipped');
         }
     } else {
         $this->_adyenLogger->addAdyenNotificationCronjob('Order can\'t be shipped');
     }
 }
開發者ID:Adyen,項目名稱:adyen-magento2,代碼行數:27,代碼來源:Cron.php

示例4: check

 /**
  * Check order status before save
  *
  * @param Order $order
  * @return $this
  */
 public function check(Order $order)
 {
     if (!$order->getId()) {
         return $order;
     }
     $userNotification = $order->hasCustomerNoteNotify() ? $order->getCustomerNoteNotify() : null;
     if (!$order->isCanceled() && !$order->canUnhold() && !$order->canInvoice() && !$order->canShip()) {
         if (0 == $order->getBaseGrandTotal() || $order->canCreditmemo()) {
             if ($order->getState() !== Order::STATE_COMPLETE) {
                 $order->setState(Order::STATE_COMPLETE, true, '', $userNotification, false);
             }
         } elseif (floatval($order->getTotalRefunded()) || !$order->getTotalRefunded() && $order->hasForcedCanCreditmemo()) {
             if ($order->getState() !== Order::STATE_CLOSED) {
                 $order->setState(Order::STATE_CLOSED, true, '', $userNotification, false);
             }
         }
     }
     if ($order->getState() == Order::STATE_NEW && $order->getIsInProcess()) {
         $order->setState(Order::STATE_PROCESSING, true, '', $userNotification);
     }
     return $this;
 }
開發者ID:pavelnovitsky,項目名稱:magento2,代碼行數:28,代碼來源:State.php


注:本文中的Magento\Sales\Model\Order::canShip方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。