Skip to content

Commit c24c12b

Browse files
committed
Revert quote items in case of an error
1 parent 06e3c7b commit c24c12b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

app/code/Magento/Quote/Model/Cart/AddProductsToCart.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ public function execute(string $maskedCartId, array $cartItems): AddProductsToCa
117117

118118
if (count($this->errors) === 0) {
119119
$this->cartRepository->save($cart);
120+
} else {
121+
/* Revert changes introduced by add to cart processes in case of an error */
122+
$cart->getItemsCollection()->clear();
120123
}
121124

122125
return $this->prepareErrorOutput($cart);

0 commit comments

Comments
 (0)