From fe71190aa4e344addd35bca5f6c093ff7b58d75c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Hrdina?= Date: Tue, 5 Sep 2023 14:14:25 +0000 Subject: [PATCH] fix: check if latest delivery exists before trying to get it's id (fixes #10) --- src/Core/Api/Transaction/Service/TransactionService.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Core/Api/Transaction/Service/TransactionService.php b/src/Core/Api/Transaction/Service/TransactionService.php index edb7f35..46128bd 100644 --- a/src/Core/Api/Transaction/Service/TransactionService.php +++ b/src/Core/Api/Transaction/Service/TransactionService.php @@ -310,7 +310,9 @@ private function holdDelivery(string $orderId, Context $context) */ $orderEntity = $this->getOrderEntity($orderId, $context); $orderDeliveryStateHandler = $this->container->get(OrderDeliveryStateHandler::class); - $orderDeliveryStateHandler->hold($orderEntity->getDeliveries()->last()->getId(), $context); + if (null !== $orderEntity->getDeliveries()->last()) { + $orderDeliveryStateHandler->hold($orderEntity->getDeliveries()->last()->getId(), $context); + } } catch (\Exception $exception) { $this->logger->critical($exception->getTraceAsString()); }