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)
523
523
);
524
524
525
525
$ qtyRecalculatedFlag = false ;
526
+ $ itemErrors = [];
526
527
foreach ($ data as $ itemId => $ itemInfo ) {
527
528
$ item = $ this ->getQuote ()->getItemById ($ itemId );
528
529
if (!$ item ) {
@@ -536,15 +537,12 @@ public function updateItems($data)
536
537
537
538
$ qty = isset ($ itemInfo ['qty ' ]) ? (double )$ itemInfo ['qty ' ] : false ;
538
539
if ($ qty > 0 ) {
539
- if ($ item ->getHasError () && !$ item ->getProduct ()->isInStock ()) {
540
- $ item ->setUseOldQty (true );
541
- }
542
540
$ item ->clearMessage ();
543
541
$ item ->setHasError (false );
544
542
$ item ->setQty ($ qty );
545
543
546
544
if ($ item ->getHasError ()) {
547
- throw new \ Magento \ Framework \ Exception \ LocalizedException ( __ ($ item ->getMessage () ));
545
+ $ itemErrors [ $ item -> getId ()] = __ ($ item ->getMessage ());
548
546
}
549
547
550
548
if (isset ($ itemInfo ['before_suggest_qty ' ]) && $ itemInfo ['before_suggest_qty ' ] != $ qty ) {
@@ -568,6 +566,10 @@ public function updateItems($data)
568
566
['cart ' => $ this , 'info ' => $ infoDataObject ]
569
567
);
570
568
569
+ if (count ($ itemErrors )) {
570
+ throw new \Magento \Framework \Exception \LocalizedException (current ($ itemErrors ));
571
+ }
572
+
571
573
return $ this ;
572
574
}
573
575
Original file line number Diff line number Diff line change @@ -594,10 +594,10 @@ private function updatePostRequest(
594
594
$ this ->dispatch ('checkout/cart/updateItemQty ' );
595
595
} else {
596
596
$ this ->dispatch ('checkout/cart/updatePost ' );
597
+ $ quote ->collectTotals ();
597
598
}
598
599
$ response = $ this ->getResponse ()->getBody ();
599
600
$ response = json_decode ($ response , true );
600
- $ quote ->collectTotals ();
601
601
return $ response ;
602
602
}
603
603
}
You can’t perform that action at this time.
0 commit comments