Skip to content

Commit

Permalink
[BUGFIX] Output all insufficientStockMessages
Browse files Browse the repository at this point in the history
  • Loading branch information
rintisch committed May 31, 2024
1 parent 7cf546c commit ff6b74f
Showing 1 changed file with 5 additions and 24 deletions.
29 changes: 5 additions & 24 deletions Classes/Controller/Cart/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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);
Expand Down

0 comments on commit ff6b74f

Please sign in to comment.