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


PHP Order::canCreditmemo方法代码示例

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


在下文中一共展示了Order::canCreditmemo方法的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: 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

示例3: _canCreditmemo

 /**
  * Check if creditmeno can be created for order
  * @param \Magento\Sales\Model\Order $order
  * @return bool
  */
 protected function _canCreditmemo($order)
 {
     /**
      * Check order existing
      */
     if (!$order->getId()) {
         $this->messageManager->addError(__('The order no longer exists.'));
         return false;
     }
     /**
      * Check creditmemo create availability
      */
     if (!$order->canCreditmemo()) {
         $this->messageManager->addError(__('We can\'t create credit memo for the order.'));
         return false;
     }
     return true;
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:23,代码来源:CreditmemoLoader.php

示例4: testCanNotCreditMemoWithForced

 public function testCanNotCreditMemoWithForced()
 {
     $this->order->setData('forced_can_creditmemo', true);
     $this->assertTrue($this->order->canCreditmemo());
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:5,代码来源:OrderTest.php


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