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


PHP Order::setActionFlag方法代码示例

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


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

示例1: _holdCancelOrder

 /**
  * @param $order
  * @return bool
  * @deprecate not needed already cancelled in ProcessController
  */
 protected function _holdCancelOrder($ignoreHasInvoice)
 {
     $orderStatus = $this->_getConfigData('payment_cancelled', 'adyen_abstract', $this->_order->getStoreId());
     // check if order has in invoice only cancel/hold if this is not the case
     if ($ignoreHasInvoice || !$this->_order->hasInvoices()) {
         $this->_order->setActionFlag($orderStatus, true);
         if ($orderStatus == \Magento\Sales\Model\Order::STATE_HOLDED) {
             if ($this->_order->canHold()) {
                 $this->_order->hold();
             } else {
                 $this->_debugData['warning'] = 'Order can not hold or is already on Hold';
                 return;
             }
         } else {
             if ($this->_order->canCancel()) {
                 $this->_order->cancel();
             } else {
                 $this->_debugData['warning'] = 'Order can not be canceled';
                 return;
             }
         }
     } else {
         $this->_debugData['warning'] = 'Order has already an invoice so cannot be canceled';
     }
 }
开发者ID:pivulic,项目名称:adyen-magento2,代码行数:30,代码来源:Cron.php

示例2: _holdCancelOrder

 /**
  * @param $ignoreHasInvoice
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _holdCancelOrder($ignoreHasInvoice)
 {
     $orderStatus = $this->_getConfigData('payment_cancelled', 'adyen_abstract', $this->_order->getStoreId());
     // check if order has in invoice only cancel/hold if this is not the case
     if ($ignoreHasInvoice || !$this->_order->hasInvoices()) {
         if ($orderStatus == \Magento\Sales\Model\Order::STATE_HOLDED) {
             // Allow magento to hold order
             $this->_order->setActionFlag(\Magento\Sales\Model\Order::ACTION_FLAG_HOLD, true);
             if ($this->_order->canHold()) {
                 $this->_order->hold();
             } else {
                 $this->_adyenLogger->addAdyenNotificationCronjob('Order can not hold or is already on Hold');
                 return;
             }
         } else {
             // Allow magento to cancel order
             $this->_order->setActionFlag(\Magento\Sales\Model\Order::ACTION_FLAG_CANCEL, true);
             if ($this->_order->canCancel()) {
                 $this->_order->cancel();
             } else {
                 $this->_adyenLogger->addAdyenNotificationCronjob('Order can not be canceled');
                 return;
             }
         }
     } else {
         $this->_adyenLogger->addAdyenNotificationCronjob('Order has already an invoice so cannot be canceled');
     }
 }
开发者ID:Adyen,项目名称:adyen-magento2,代码行数:32,代码来源:Cron.php

示例3: testCanCancelActionFlag

    /**
     * @param bool $cancelActionFlag
     * @dataProvider dataProviderActionFlag
     */
    public function testCanCancelActionFlag($cancelActionFlag)
    {
        $paymentMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\Payment')
            ->disableOriginalConstructor()
            ->setMethods(['isDeleted', 'canReviewPayment', 'canFetchTransactionInfo', '__wakeUp'])
            ->getMock();
        $paymentMock->expects($this->any())
            ->method('canReviewPayment')
            ->will($this->returnValue(false));
        $paymentMock->expects($this->any())
            ->method('canFetchTransactionInfo')
            ->will($this->returnValue(false));

        $this->preparePaymentMock($paymentMock);

        $this->prepareItemMock(1);

        $actionFlags = [
            \Magento\Sales\Model\Order::ACTION_FLAG_UNHOLD => false,
            \Magento\Sales\Model\Order::ACTION_FLAG_CANCEL => $cancelActionFlag,
        ];
        foreach ($actionFlags as $action => $flag) {
            $this->order->setActionFlag($action, $flag);
        }
        $this->order->setData('state', \Magento\Sales\Model\Order::STATE_NEW);

        $this->item->expects($this->any())
            ->method('isDeleted')
            ->willReturn(false);
        $this->item->expects($this->any())
            ->method('getQtyToInvoice')
            ->willReturn(42);

        $this->assertEquals($cancelActionFlag, $this->order->canCancel());
    }
开发者ID:nblair,项目名称:magescotch,代码行数:39,代码来源:OrderTest.php


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