Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
StateResolver.php
Go to the documentation of this file.
1 <?php
7 
10 
15 {
22  private function isOrderComplete(OrderInterface $order)
23  {
25  if (0 == $order->getBaseGrandTotal() || $order->canCreditmemo()) {
26  return true;
27  }
28  return false;
29  }
30 
38  private function isOrderClosed(OrderInterface $order, $arguments)
39  {
41  $forceCreditmemo = in_array(self::FORCED_CREDITMEMO, $arguments);
42  if ((float)$order->getTotalRefunded() || !$order->getTotalRefunded() && $forceCreditmemo) {
43  return true;
44  }
45  return false;
46  }
47 
55  private function isOrderProcessing(OrderInterface $order, $arguments)
56  {
58  if ($order->getState() == Order::STATE_NEW && in_array(self::IN_PROGRESS, $arguments)) {
59  return true;
60  }
61  return false;
62  }
63 
70  private function getInitialOrderState(OrderInterface $order)
71  {
73  }
74 
80  public function getStateForOrder(OrderInterface $order, array $arguments = [])
81  {
83  $orderState = $this->getInitialOrderState($order);
84  if (!$order->isCanceled() && !$order->canUnhold() && !$order->canInvoice() && !$order->canShip()) {
85  if ($this->isOrderComplete($order)) {
86  $orderState = Order::STATE_COMPLETE;
87  } elseif ($this->isOrderClosed($order, $arguments)) {
88  $orderState = Order::STATE_CLOSED;
89  }
90  }
91  if ($this->isOrderProcessing($order, $arguments)) {
92  $orderState = Order::STATE_PROCESSING;
93  }
94  return $orderState;
95  }
96 }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
$order
Definition: order.php:55
$arguments
getStateForOrder(OrderInterface $order, array $arguments=[])