File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed
app/code/Magento/Checkout/Model
dev/tests/integration/testsuite/Magento/Checkout/Controller Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -523,6 +523,7 @@ public function updateItems($data)
523523 );
524524
525525 $ qtyRecalculatedFlag = false ;
526+ $ itemErrors = [];
526527 foreach ($ data as $ itemId => $ itemInfo ) {
527528 $ item = $ this ->getQuote ()->getItemById ($ itemId );
528529 if (!$ item ) {
@@ -536,15 +537,12 @@ public function updateItems($data)
536537
537538 $ qty = isset ($ itemInfo ['qty ' ]) ? (double )$ itemInfo ['qty ' ] : false ;
538539 if ($ qty > 0 ) {
539- if ($ item ->getHasError () && !$ item ->getProduct ()->isInStock ()) {
540- $ item ->setUseOldQty (true );
541- }
542540 $ item ->clearMessage ();
543541 $ item ->setHasError (false );
544542 $ item ->setQty ($ qty );
545543
546544 if ($ item ->getHasError ()) {
547- throw new \ Magento \ Framework \ Exception \ LocalizedException ( __ ($ item ->getMessage () ));
545+ $ itemErrors [ $ item -> getId ()] = __ ($ item ->getMessage ());
548546 }
549547
550548 if (isset ($ itemInfo ['before_suggest_qty ' ]) && $ itemInfo ['before_suggest_qty ' ] != $ qty ) {
@@ -568,6 +566,10 @@ public function updateItems($data)
568566 ['cart ' => $ this , 'info ' => $ infoDataObject ]
569567 );
570568
569+ if (count ($ itemErrors )) {
570+ throw new \Magento \Framework \Exception \LocalizedException (current ($ itemErrors ));
571+ }
572+
571573 return $ this ;
572574 }
573575
Original file line number Diff line number Diff line change @@ -594,10 +594,10 @@ private function updatePostRequest(
594594 $ this ->dispatch ('checkout/cart/updateItemQty ' );
595595 } else {
596596 $ this ->dispatch ('checkout/cart/updatePost ' );
597+ $ quote ->collectTotals ();
597598 }
598599 $ response = $ this ->getResponse ()->getBody ();
599600 $ response = json_decode ($ response , true );
600- $ quote ->collectTotals ();
601601 return $ response ;
602602 }
603603}
You can’t perform that action at this time.
0 commit comments