本文整理汇总了PHP中Magento\Sales\Model\Order::isCanceled方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::isCanceled方法的具体用法?PHP Order::isCanceled怎么用?PHP Order::isCanceled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Sales\Model\Order
的用法示例。
在下文中一共展示了Order::isCanceled方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: 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;
}
示例3: _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'));
}
}
示例4: _processNotification
/**
* Process the Notification
*/
protected function _processNotification()
{
$this->_adyenLogger->addAdyenNotificationCronjob('Processing the notification');
$_paymentCode = $this->_paymentMethodCode();
switch ($this->_eventCode) {
case Notification::REFUND_FAILED:
// do nothing only inform the merchant with order comment history
break;
case Notification::REFUND:
$ignoreRefundNotification = $this->_getConfigData('ignore_refund_notification', 'adyen_abstract', $this->_order->getStoreId());
if ($ignoreRefundNotification != true) {
$this->_refundOrder();
//refund completed
$this->_setRefundAuthorized();
} else {
$this->_adyenLogger->addAdyenNotificationCronjob('Setting to ignore refund notification is enabled so ignore this notification');
}
break;
case Notification::PENDING:
if ($this->_getConfigData('send_email_bank_sepa_on_pending', 'adyen_abstract', $this->_order->getStoreId())) {
// Check if payment is banktransfer or sepa if true then send out order confirmation email
$isBankTransfer = $this->_isBankTransfer();
if ($isBankTransfer || $this->_paymentMethod == 'sepadirectdebit') {
if (!$this->_order->getEmailSent()) {
$this->_orderSender->send($this->_order);
$this->_adyenLogger->addAdyenNotificationCronjob('Send orderconfirmation email to shopper');
}
}
}
break;
case Notification::HANDLED_EXTERNALLY:
case Notification::AUTHORISATION:
// for POS don't do anything on the AUTHORIZATION
if ($_paymentCode != "adyen_pos") {
$this->_authorizePayment();
}
break;
case Notification::MANUAL_REVIEW_REJECT:
// don't do anything it will send a CANCEL_OR_REFUND notification when this payment is captured
break;
case Notification::MANUAL_REVIEW_ACCEPT:
/*
* only process this if you are on auto capture.
* On manual capture you will always get Capture or CancelOrRefund notification
*/
if ($this->_isAutoCapture()) {
$this->_setPaymentAuthorized(false);
}
break;
case Notification::CAPTURE:
if ($_paymentCode != "adyen_pos") {
/*
* ignore capture if you are on auto capture
* this could be called if manual review is enabled and you have a capture delay
*/
if (!$this->_isAutoCapture()) {
$this->_setPaymentAuthorized(false, true);
}
} else {
// FOR POS authorize the payment on the CAPTURE notification
$this->_authorizePayment();
}
break;
case Notification::CAPTURE_FAILED:
case Notification::CANCELLATION:
case Notification::CANCELLED:
$this->_holdCancelOrder(true);
break;
case Notification::CANCEL_OR_REFUND:
if (isset($this->_modificationResult) && $this->_modificationResult != "") {
if ($this->_modificationResult == "cancel") {
$this->_holdCancelOrder(true);
} elseif ($this->_modificationResult == "refund") {
$this->_refundOrder();
//refund completed
$this->_setRefundAuthorized();
}
} else {
if ($this->_order->isCanceled() || $this->_order->getState() === \Magento\Sales\Model\Order::STATE_HOLDED) {
$this->_adyenLogger->addAdyenNotificationCronjob('Order is already cancelled or holded so do nothing');
} else {
if ($this->_order->canCancel() || $this->_order->canHold()) {
$this->_adyenLogger->addAdyenNotificationCronjob('try to cancel the order');
$this->_holdCancelOrder(true);
} else {
$this->_adyenLogger->addAdyenNotificationCronjob('try to refund the order');
// refund
$this->_refundOrder();
//refund completed
$this->_setRefundAuthorized();
}
}
}
break;
case Notification::RECURRING_CONTRACT:
// storedReferenceCode
$recurringDetailReference = $this->_pspReference;
//.........这里部分代码省略.........
示例5: _processNotification
/**
* @param $params
*/
protected function _processNotification()
{
$this->_debugData['_processNotification'] = 'Processing the notification';
$_paymentCode = $this->_paymentMethodCode();
switch ($this->_eventCode) {
case Notification::REFUND_FAILED:
// do nothing only inform the merchant with order comment history
break;
case Notification::REFUND:
$ignoreRefundNotification = $this->_getConfigData('ignore_refund_notification', 'adyen_abstract', $this->_order->getStoreId());
if ($ignoreRefundNotification != true) {
$this->_refundOrder();
//refund completed
$this->_setRefundAuthorized();
} else {
$this->_debugData['_processNotification info'] = 'Setting to ignore refund notification is enabled so ignore this notification';
}
break;
case Notification::PENDING:
if ($this->_getConfigData('send_email_bank_sepa_on_pending', 'adyen_abstract', $this->_order->getStoreId())) {
// Check if payment is banktransfer or sepa if true then send out order confirmation email
$isBankTransfer = $this->_isBankTransfer($this->_paymentMethod);
if ($isBankTransfer || $this->_paymentMethod == 'sepadirectdebit') {
// $this->_order->sendNewOrderEmail(); // send order email
$this->_orderSender->send($this->_order);
$this->_debugData['_processNotification send email'] = 'Send orderconfirmation email to shopper';
}
}
break;
case Notification::HANDLED_EXTERNALLY:
case Notification::AUTHORISATION:
// for POS don't do anything on the AUTHORIZATION
if ($_paymentCode != "adyen_pos") {
$this->_authorizePayment();
}
break;
case Notification::MANUAL_REVIEW_REJECT:
// don't do anything it will send a CANCEL_OR_REFUND notification when this payment is captured
break;
case Notification::MANUAL_REVIEW_ACCEPT:
// only process this if you are on auto capture. On manual capture you will always get Capture or CancelOrRefund notification
if ($this->_isAutoCapture()) {
$this->_setPaymentAuthorized(false);
}
break;
case Notification::CAPTURE:
if ($_paymentCode != "adyen_pos") {
// ignore capture if you are on auto capture (this could be called if manual review is enabled and you have a capture delay)
if (!$this->_isAutoCapture()) {
$this->_setPaymentAuthorized(false, true);
}
} else {
// uncancel the order just to be sure that order is going trough
// $this->_uncancelOrder($this->_order);
// FOR POS authorize the payment on the CAPTURE notification
$this->_authorizePayment($this->_order, $this->_paymentMethod);
}
break;
case Notification::CAPTURE_FAILED:
case Notification::CANCELLATION:
case Notification::CANCELLED:
$this->_holdCancelOrder(true);
break;
case Notification::CANCEL_OR_REFUND:
if (isset($this->_modificationResult) && $this->_modificationResult != "") {
if ($this->_modificationResult == "cancel") {
$this->_holdCancelOrder(true);
} elseif ($this->_modificationResult == "refund") {
$this->_refundOrder();
//refund completed
$this->_setRefundAuthorized();
}
} else {
if ($this->_order->isCanceled() || $this->_order->getState() === \Magento\Sales\Model\Order::STATE_HOLDED) {
$this->_debugData['_processNotification info'] = 'Order is already cancelled or holded so do nothing';
} else {
if ($this->_order->canCancel() || $this->_order->canHold()) {
$this->_debugData['_processNotification info'] = 'try to cancel the order';
$this->_holdCancelOrder($this->_order, true);
} else {
$this->_debugData['_processNotification info'] = 'try to refund the order';
// refund
$this->_refundOrder();
//refund completed
$this->_setRefundAuthorized();
}
}
}
break;
default:
$this->_order->getPayment()->getMethodInstance()->writeLog('notification event not supported!');
break;
}
}