File tree Expand file tree Collapse file tree 3 files changed +16
-9
lines changed
app/code/Magento/Checkout Expand file tree Collapse file tree 3 files changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -129,12 +129,12 @@ public function execute()
129
129
private function updateItemQuantity (Item $ item , float $ qty )
130
130
{
131
131
if ($ qty > 0 ) {
132
- $ item ->clearMessage ();
133
- $ item ->setHasError (false );
134
- $ item ->setQty ($ qty );
135
-
136
132
if ($ item ->getHasError ()) {
137
133
throw new LocalizedException (__ ($ item ->getMessage ()));
134
+ } else {
135
+ $ item ->clearMessage ();
136
+ $ item ->setHasError (false );
137
+ $ item ->setQty ($ qty );
138
138
}
139
139
}
140
140
}
Original file line number Diff line number Diff line change @@ -83,6 +83,7 @@ protected function _updateShoppingCart()
83
83
$ this ->cart ->updateItems ($ cartData )->save ();
84
84
}
85
85
} catch (\Magento \Framework \Exception \LocalizedException $ e ) {
86
+ $ this ->cart ->save ();
86
87
$ this ->messageManager ->addErrorMessage (
87
88
$ this ->_objectManager ->get (\Magento \Framework \Escaper::class)->escapeHtml ($ e ->getMessage ())
88
89
);
Original file line number Diff line number Diff line change @@ -522,6 +522,7 @@ public function updateItems($data)
522
522
);
523
523
524
524
$ qtyRecalculatedFlag = false ;
525
+ $ deferredErrors = [];
525
526
foreach ($ data as $ itemId => $ itemInfo ) {
526
527
$ item = $ this ->getQuote ()->getItemById ($ itemId );
527
528
if (!$ item ) {
@@ -535,12 +536,13 @@ public function updateItems($data)
535
536
536
537
$ qty = isset ($ itemInfo ['qty ' ]) ? (double )$ itemInfo ['qty ' ] : false ;
537
538
if ($ qty > 0 ) {
538
- $ item ->clearMessage ();
539
- $ item ->setHasError (false );
540
- $ item ->setQty ($ qty );
541
-
542
539
if ($ item ->getHasError ()) {
543
- throw new \Magento \Framework \Exception \LocalizedException (__ ($ item ->getMessage ()));
540
+ $ deferredErrors [$ item ->getId ()] = __ ($ item ->getMessage ());
541
+ continue ;
542
+ } else {
543
+ $ item ->clearMessage ();
544
+ $ item ->setHasError (false );
545
+ $ item ->setQty ($ qty );
544
546
}
545
547
546
548
if (isset ($ itemInfo ['before_suggest_qty ' ]) && $ itemInfo ['before_suggest_qty ' ] != $ qty ) {
@@ -564,6 +566,10 @@ public function updateItems($data)
564
566
['cart ' => $ this , 'info ' => $ infoDataObject ]
565
567
);
566
568
569
+ if (count ($ deferredErrors )) {
570
+ throw new \Magento \Framework \Exception \LocalizedException (current ($ deferredErrors ));
571
+ }
572
+
567
573
return $ this ;
568
574
}
569
575
You can’t perform that action at this time.
0 commit comments