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


PHP Order::canInvoice方法代碼示例

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


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

示例1: testCanNotInvoiceWhenDidNotHaveQtyToInvoice

 public function testCanNotInvoiceWhenDidNotHaveQtyToInvoice()
 {
     $this->item->expects($this->any())
         ->method('getQtyToInvoice')
         ->willReturn(0);
     $this->item->expects($this->any())
         ->method('getLockedDoInvoice')
         ->willReturn(false);
     $this->assertFalse($this->order->canInvoice());
 }
開發者ID:nblair,項目名稱:magescotch,代碼行數:10,代碼來源:OrderTest.php

示例2: _createInvoice

 /**
  * @throws Exception
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _createInvoice()
 {
     $this->_adyenLogger->addAdyenNotificationCronjob('Creating invoice for order');
     if ($this->_order->canInvoice()) {
         /* We do not use this inside a transaction because order->save()
          * is always done on the end of the notification
          * and it could result in a deadlock see https://github.com/Adyen/magento/issues/334
          */
         try {
             $invoice = $this->_order->prepareInvoice();
             $invoice->getOrder()->setIsInProcess(true);
             // set transaction id so you can do a online refund from credit memo
             $invoice->setTransactionId($this->_pspReference);
             $autoCapture = $this->_isAutoCapture();
             $createPendingInvoice = (bool) $this->_getConfigData('create_pending_invoice', 'adyen_abstract', $this->_order->getStoreId());
             if (!$autoCapture && $createPendingInvoice) {
                 // if amount is zero create a offline invoice
                 $value = (int) $this->_value;
                 if ($value == 0) {
                     $invoice->setRequestedCaptureCase(\Magento\Sales\Model\Order\Invoice::CAPTURE_OFFLINE);
                 } else {
                     $invoice->setRequestedCaptureCase(\Magento\Sales\Model\Order\Invoice::NOT_CAPTURE);
                 }
                 $invoice->register();
             } else {
                 $invoice->register()->pay();
             }
             $invoice->save();
             $this->_adyenLogger->addAdyenNotificationCronjob('Created invoice');
         } catch (Exception $e) {
             $this->_adyenLogger->addAdyenNotificationCronjob('Error saving invoice. The error message is: ' . $e->getMessage());
             throw new Exception(sprintf('Error saving invoice. The error message is:', $e->getMessage()));
         }
         $this->_setPaymentAuthorized();
         $invoiceAutoMail = (bool) $this->_getConfigData('send_invoice_update_mail', 'adyen_abstract', $this->_order->getStoreId());
         if ($invoiceAutoMail) {
             $invoice->sendEmail();
         }
     } else {
         $this->_adyenLogger->addAdyenNotificationCronjob('It is not possible to create invoice for this order');
     }
 }
開發者ID:Adyen,項目名稱:adyen-magento2,代碼行數:46,代碼來源:Cron.php

示例3: 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

示例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

示例5: _createInvoice

 protected function _createInvoice($params)
 {
     try {
         if ($this->_order->canInvoice()) {
             $payment = $this->_order->getPayment();
             $payment->setTransactionId($params['invoice_id']);
             $payment->setCurrencyCode($params['list_currency']);
             $payment->setParentTransactionId($params['sale_id']);
             $payment->setShouldCloseParentTransaction(true);
             $payment->setIsTransactionClosed(0);
             $payment->registerCaptureNotification($params['invoice_list_amount'], true);
             $this->_order->save();
             // notify customer
             $invoice = $payment->getCreatedInvoice();
             if ($invoice && !$this->_order->getEmailSent()) {
                 $this->orderSender->send($this->_order);
                 $this->_order->addStatusHistoryComment(__('You notified customer about invoice #%1.', $invoice->getIncrementId()))->setIsCustomerNotified(true)->save();
             }
         }
     } catch (Exception $e) {
         throw new Exception(sprintf('Error Creating Invoice: "%s"', $e->getMessage()));
     }
 }
開發者ID:craigchristenson,項目名稱:magento2-2checkout,代碼行數:23,代碼來源:Notification.php

示例6: _processInvoice

 protected function _processInvoice()
 {
     if ($this->_order->canInvoice()) {
         $invoice = $this->_order->prepareInvoice();
         switch ($this->_paymentInst->getConfigPaymentAction()) {
             case \Magento\Payment\Model\Method\AbstractMethod::ACTION_AUTHORIZE:
                 $invoice->register();
                 $this->_order->setState(\Magento\Sales\Model\Order::STATE_PROCESSING, 'authorized');
                 break;
             case \Magento\Payment\Model\Method\AbstractMethod::ACTION_AUTHORIZE_CAPTURE:
                 $this->_paymentInst->setAssistCaptureResponse(true);
                 $invoice->register()->capture();
                 break;
         }
         /** @var \Magento\Framework\DB\Transaction $transaction */
         $transaction = $this->_transactionFactory->create();
         $transaction->addObject($invoice)->addObject($invoice->getOrder())->save();
         $this->_invoiceSender->send($invoice);
     } elseif ($this->_order->isCanceled()) {
         throw new \Magento\Framework\Exception\LocalizedException(__('Order canceled'));
     } else {
         throw new \Magento\Framework\Exception\LocalizedException(__('Order paid'));
     }
 }
開發者ID:vuleticd,項目名稱:vuleticd_assist2,代碼行數:24,代碼來源:Ipn.php


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