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


PHP Order::addStatusHistoryComment方法代码示例

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


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

示例1: _createIpnComment

 /**
  * Generate an "IPN" comment with additional explanation.
  * Returns the generated comment or order status history object
  *
  * @param string $comment
  * @param bool $addToHistory
  * @return string|\Magento\Sales\Model\Order\Status\History
  */
 protected function _createIpnComment($comment = '', $addToHistory = false)
 {
     $message = __('IPN "%1"', $this->getRequestData('payment_status'));
     if ($comment) {
         $message .= ' ' . $comment;
     }
     if ($addToHistory) {
         $message = $this->_order->addStatusHistoryComment($message);
         $message->setIsCustomerNotified(null);
     }
     return $message;
 }
开发者ID:nja78,项目名称:magento2,代码行数:20,代码来源:Ipn.php

示例2: _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

示例3: confirmOrder

 /**
  * Confirm the payment of an order
  *
  * @param \Magento\Sales\Model\Order $order
  * @param \WirecardCEE_Stdlib_Return_ReturnAbstract $return
  * @param bool $fraudDetected
  *
  * @return Order
  *
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function confirmOrder($order, $return, $fraudDetected)
 {
     /** @var \Magento\Sales\Model\Order\Payment $payment */
     $payment = $order->getPayment();
     /** @var \Wirecard\CheckoutPage\Model\AbstractPayment $paymentInstance */
     $paymentInstance = $payment->getMethodInstance();
     $additionalInformation = array();
     foreach ($return->getReturned() as $fieldName => $fieldValue) {
         $additionalInformation[htmlentities($fieldName)] = htmlentities($fieldValue);
     }
     $payment->setAdditionalInformation($additionalInformation);
     if ($fraudDetected) {
         $order->setStatus(\Magento\Sales\Model\Order::STATUS_FRAUD);
         $message = $this->_dataHelper->__('fraud attemmpt detected, cart has been modified during checkout!');
         $this->_logger->debug(__METHOD__ . ':' . $message);
         $order->addStatusHistoryComment($message);
     }
     $doCapture = false;
     if (!$this->isOrderProcessed($order)) {
         if ($return->getPaymentState() == \WirecardCEE_QPay_ReturnFactory::STATE_PENDING) {
             /** @var \WirecardCEE_QPay_Return_Pending $return */
             $order->setState(\Magento\Sales\Model\Order::STATE_PENDING_PAYMENT);
             $message = $this->_dataHelper->__('The payment authorization is pending.');
         } else {
             /** @var \WirecardCEE_QPay_Return_Success $return */
             $order->setState(\Magento\Sales\Model\Order::STATE_PROCESSING);
             $order->setStatus(\Magento\Sales\Model\Order::STATE_PROCESSING);
             $message = $this->_dataHelper->__('The payment has been successfully completed.');
             // invoice payment
             if ($order->canInvoice()) {
                 $invoice = $order->prepareInvoice();
                 $invoice->register();
                 /* capture invoice if toolkit is not availble */
                 if (!$this->_dataHelper->isBackendAvailable()) {
                     $doCapture = true;
                 } else {
                     $hasBackedOps = false;
                     $orderDetails = $paymentInstance->getOrderDetails($payment->getAdditionalInformation('orderNumber'));
                     foreach ($orderDetails->getOrder()->getPayments() as $wdPayment) {
                         /** @var \WirecardCEE_QPay_Response_Toolkit_Order_Payment $wdPayment */
                         $this->_logger->debug(__METHOD__ . ':payment-state:' . $wdPayment->getState() . ' allowed operations:' . implode(',', $wdPayment->getOperationsAllowed()));
                         if (count($wdPayment->getOperationsAllowed())) {
                             $hasBackedOps = true;
                             break;
                         }
                     }
                     if (count($orderDetails->getOrder()->getOperationsAllowed())) {
                         $this->_logger->debug(__METHOD__ . ':order allowed operations: ' . implode(',', $orderDetails->getOrder()->getOperationsAllowed()));
                         $hasBackedOps = true;
                     }
                     /* no backend ops allowed anymore, assume final state of payment, capture invoice */
                     if (!$hasBackedOps) {
                         $doCapture = true;
                     }
                 }
                 if ($doCapture && !$fraudDetected) {
                     $invoice->capture();
                 }
                 $order->addRelatedObject($invoice);
             }
             $this->_orderSender->send($order);
         }
         $type = $doCapture ? Transaction::TYPE_CAPTURE : Transaction::TYPE_AUTH;
         $this->saveTransaction($type, $message, $order, $return);
     }
     $order->save();
     return $order;
 }
开发者ID:wirecard,项目名称:magento2-wcp,代码行数:79,代码来源:OrderManagement.php

示例4: _setPaymentAuthorized

 /**
  * @param bool $manualReviewComment
  * @param bool $createInvoice
  * @throws Exception
  */
 protected function _setPaymentAuthorized($manualReviewComment = true, $createInvoice = false)
 {
     $this->_adyenLogger->addAdyenNotificationCronjob('Set order to authorised');
     // if full amount is captured create invoice
     $currency = $this->_order->getOrderCurrencyCode();
     $amount = $this->_value;
     $orderAmount = (int) $this->_adyenHelper->formatAmount($this->_order->getGrandTotal(), $currency);
     // create invoice for the capture notification if you are on manual capture
     if ($createInvoice == true && $amount == $orderAmount) {
         $this->_adyenLogger->addAdyenNotificationCronjob('amount notification:' . $amount . ' amount order:' . $orderAmount);
         $this->_createInvoice();
     }
     // if you have capture on shipment enabled don't set update the status of the payment
     $captureOnShipment = $this->_getConfigData('capture_on_shipment', 'adyen_abstract', $this->_order->getStoreId());
     if (!$captureOnShipment) {
         $status = $this->_getConfigData('payment_authorized', 'adyen_abstract', $this->_order->getStoreId());
     }
     // virtual order can have different status
     if ($this->_order->getIsVirtual()) {
         $this->_adyenLogger->addAdyenNotificationCronjob('Product is a virtual product');
         $virtualStatus = $this->_getConfigData('payment_authorized_virtual');
         if ($virtualStatus != "") {
             $status = $virtualStatus;
         }
     }
     // check for boleto if payment is totally paid
     if ($this->_paymentMethodCode() == "adyen_boleto") {
         // check if paid amount is the same as orginal amount
         $orginalAmount = $this->_boletoOriginalAmount;
         $paidAmount = $this->_boletoPaidAmount;
         if ($orginalAmount != $paidAmount) {
             // not the full amount is paid. Check if it is underpaid or overpaid
             // strip the  BRL of the string
             $orginalAmount = str_replace("BRL", "", $orginalAmount);
             $orginalAmount = floatval(trim($orginalAmount));
             $paidAmount = str_replace("BRL", "", $paidAmount);
             $paidAmount = floatval(trim($paidAmount));
             if ($paidAmount > $orginalAmount) {
                 $overpaidStatus = $this->_getConfigData('order_overpaid_status', 'adyen_boleto');
                 // check if there is selected a status if not fall back to the default
                 $status = !empty($overpaidStatus) ? $overpaidStatus : $status;
             } else {
                 $underpaidStatus = $this->_getConfigData('order_underpaid_status', 'adyen_boleto');
                 // check if there is selected a status if not fall back to the default
                 $status = !empty($underpaidStatus) ? $underpaidStatus : $status;
             }
         }
     }
     $comment = "Adyen Payment Successfully completed";
     // if manual review is true use the manual review status if this is set
     if ($manualReviewComment == true && $this->_fraudManualReview) {
         // check if different status is selected
         $fraudManualReviewStatus = $this->_getFraudManualReviewStatus();
         if ($fraudManualReviewStatus != "") {
             $status = $fraudManualReviewStatus;
             $comment = "Adyen Payment is in Manual Review check the Adyen platform";
         }
     }
     $status = !empty($status) ? $status : $this->_order->getStatus();
     $this->_order->addStatusHistoryComment(__($comment), $status);
     $this->_adyenLogger->addAdyenNotificationCronjob('Order status is changed to authorised status, status is ' . $status);
 }
开发者ID:Adyen,项目名称:adyen-magento2,代码行数:67,代码来源:Cron.php


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