Skip to content

Commit

Permalink
[ENGA3-728]: Added a logic to reverse the cancelled items before chan…
Browse files Browse the repository at this point in the history
…ging order status from cancelled to processing. (#406)
  • Loading branch information
aashishgurung authored Dec 19, 2022
1 parent 39dc871 commit e721b7e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Model/SyncStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ private function markPaymentSuccessful($order, $charge)
$orderStates = [Order::STATE_COMPLETE, Order::STATE_CLOSED, Order::STATE_PROCESSING];

if (!in_array($order->getState(), $orderStates)) {
if ($order->getState() === Order::STATE_CANCELED) {
$this->reverseCancelledItems($order);
}

$order->setState(Order::STATE_PROCESSING);
$order->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_PROCESSING));

Expand All @@ -130,6 +134,21 @@ private function markPaymentSuccessful($order, $charge)
}
}

/**
* Setting the item status from cancelled to ordered to properly set the order status
*
* @return void
*/
private function reverseCancelledItems($order)
{
$items = $order->getAllItems();

foreach ($items as $item) {
$item->setQtyCanceled(0);
$item->save();
}
}

/**
* @param Order $order
* @param array $charge
Expand Down

0 comments on commit e721b7e

Please sign in to comment.