Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fix issue #20 #21

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/Core/Api/WebHooks/Controller/WebHookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -642,13 +642,19 @@ private function unholdDelivery(string $orderId, Context $context): void
* @var OrderDeliveryStateHandler $orderDeliveryStateHandler
*/
$order = $this->getOrderEntity($orderId, $context);

/**
* @var OrderDeliveryEntity $orderDelivery
*/
$orderDelivery = $order->getDeliveries()->last();
if ($orderDelivery->getStateMachineState()?->getTechnicalName() !== OrderDeliveryStateHandler::STATE_HOLD){
* @var OrderDeliveryEntity $orderDelivery
*/
$orderDelivery = $order->getDeliveries()?->last();
if (null === $orderDelivery) {
return;
}

if ($orderDelivery->getStateMachineState()?->getTechnicalName() !== OrderDeliveryStateHandler::STATE_HOLD) {
return;
}

$orderDeliveryStateHandler = $this->container->get(OrderDeliveryStateHandler::class);
$orderDeliveryStateHandler->unhold($orderDelivery->getId(), $context);
} catch (\Exception $exception) {
Expand Down Expand Up @@ -684,7 +690,11 @@ private function unholdAndCancelDelivery(string $orderId, Context $context): voi
/**
* @var OrderDeliveryEntity $orderDelivery
*/
$orderDelivery = $order->getDeliveries()->last();
$orderDelivery = $order->getDeliveries()?->last();
if (null === $orderDelivery) {
return;
}

if ($orderDelivery->getStateMachineState()?->getTechnicalName() !== OrderDeliveryStateHandler::STATE_HOLD){
return;
}
Expand Down
5 changes: 4 additions & 1 deletion src/Core/Api/WebHooks/Strategy/WebHookStrategyBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,10 @@ protected function unholdDelivery(string $orderId, Context $context): void
try {
$order = $this->getOrderEntity($orderId, $context);
/** @var OrderDeliveryEntity $orderDelivery */
$orderDelivery = $order->getDeliveries()->last();
$orderDelivery = $order->getDeliveries()?->last();
if (null === $orderDelivery) {
return;
}
if ($orderDelivery->getStateMachineState()?->getTechnicalName() !== OrderDeliveryStateHandler::STATE_HOLD){
return;
}
Expand Down