From ff6b74f326d1315ae211ff9e267e93c843dbda92 Mon Sep 17 00:00:00 2001 From: rintisch Date: Fri, 31 May 2024 06:15:48 +0200 Subject: [PATCH] [BUGFIX] Output all insufficientStockMessages --- Classes/Controller/Cart/OrderController.php | 29 ++++----------------- 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/Classes/Controller/Cart/OrderController.php b/Classes/Controller/Cart/OrderController.php index 383f41b8..e38ce8e0 100644 --- a/Classes/Controller/Cart/OrderController.php +++ b/Classes/Controller/Cart/OrderController.php @@ -89,29 +89,11 @@ public function createAction( $this->eventDispatcher->dispatch($processOrderCheckStockEvent); if (!$processOrderCheckStockEvent->isEveryProductAvailable()) { - $errors = $processOrderCheckStockEvent->getInsufficientStockMessages(); - - $messageBody = ''; - $messageTitle = ''; - $severity = ContextualFeedbackSeverity::OK; - - foreach ($errors as $error) { - if (!($error instanceof AbstractMessage)) { - continue; - } - $message = $error->jsonSerialize(); - if ($message['severity'] >= (int)$severity) { - $severity = $message['severity']; - $messageBody = $message['message']; - $messageTitle = $message['title']; - } - - $this->addFlashMessage( - $messageBody, - $messageTitle, - $severity, - true - ); + $insufficientStockMessages = $processOrderCheckStockEvent->getInsufficientStockMessages(); + + foreach ($insufficientStockMessages as $insufficientStockMessage) { + $insufficientStockMessage->setStoreInSession(true); + $this->getFlashMessageQueue()->enqueue($insufficientStockMessage); } return $this->redirect('show', 'Cart\Cart'); @@ -120,7 +102,6 @@ public function createAction( $orderItem->setCartPid((int)$this->settings['cart']['pid']); // add billing and shipping address to order - $storagePid = (int)$this->settings['order']['pid']; $billingAddress->setPid($storagePid); $orderItem->setBillingAddress($billingAddress);