Skip to content

Commit 06e3c7b

Browse files
committed
Save quote if there are no errors only
1 parent 394dd7e commit 06e3c7b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ public function execute(string $maskedCartId, array $cartItems): AddProductsToCa
105105
foreach ($cartItems as $cartItemPosition => $cartItem) {
106106
$this->addItemToCart($cart, $cartItem, $cartItemPosition);
107107
}
108+
108109
if ($cart->getData('has_error')) {
109110
$errors = $cart->getErrors();
110111

@@ -113,7 +114,10 @@ public function execute(string $maskedCartId, array $cartItems): AddProductsToCa
113114
$this->addError($error->getText());
114115
}
115116
}
116-
$this->cartRepository->save($cart);
117+
118+
if (count($this->errors) === 0) {
119+
$this->cartRepository->save($cart);
120+
}
117121

118122
return $this->prepareErrorOutput($cart);
119123
}

0 commit comments

Comments
 (0)