10
10
use Magento \Checkout \Controller \Cart ;
11
11
use Magento \Checkout \Controller \Sidebar \UpdateItemQty ;
12
12
use Magento \Checkout \Model \Session ;
13
+ use Magento \Checkout \Model \Cart as CartModel ;
13
14
use Magento \Customer \Api \AddressRepositoryInterface ;
14
15
use Magento \Framework \App \RequestInterface ;
15
16
use Magento \Framework \Exception \LocalizedException ;
19
20
20
21
/**
21
22
* Cleans shipping addresses and item assignments after MultiShipping flow
23
+ *
24
+ * @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
22
25
*/
23
26
class MultishippingClearItemAddress
24
27
{
@@ -42,22 +45,30 @@ class MultishippingClearItemAddress
42
45
*/
43
46
private $ disableMultishipping ;
44
47
48
+ /**
49
+ * @var CartModel
50
+ */
51
+ private $ cartmodel ;
52
+
45
53
/**
46
54
* @param CartRepositoryInterface $cartRepository
47
55
* @param Session $checkoutSession
48
56
* @param AddressRepositoryInterface $addressRepository
49
57
* @param DisableMultishipping $disableMultishipping
58
+ * @param CartModel $cartmodel
50
59
*/
51
60
public function __construct (
52
61
CartRepositoryInterface $ cartRepository ,
53
62
Session $ checkoutSession ,
54
63
AddressRepositoryInterface $ addressRepository ,
55
- DisableMultishipping $ disableMultishipping
64
+ DisableMultishipping $ disableMultishipping ,
65
+ CartModel $ cartmodel
56
66
) {
57
67
$ this ->cartRepository = $ cartRepository ;
58
68
$ this ->checkoutSession = $ checkoutSession ;
59
69
$ this ->addressRepository = $ addressRepository ;
60
70
$ this ->disableMultishipping = $ disableMultishipping ;
71
+ $ this ->cartmodel = $ cartmodel ;
61
72
}
62
73
63
74
/**
@@ -90,9 +101,8 @@ public function clearAddressItem($subject, $request)
90
101
}
91
102
$ this ->cartRepository ->save ($ quote );
92
103
if ($ subject instanceof UpdateItemQty) {
93
- $ quote = $ this ->checkoutSession ->getQuote ();
94
- $ quote ->setTotalsCollectedFlag (false );
95
- $ this ->cartRepository ->save ($ quote );
104
+ $ quote = $ this ->cartRepository ->get ($ quote ->getId ());
105
+ $ this ->cartmodel ->setQuote ($ quote );
96
106
}
97
107
} elseif ($ this ->disableMultishipping ->execute ($ quote ) && $ this ->isVirtualItemInQuote ($ quote )) {
98
108
$ quote ->setTotalsCollectedFlag (false );
0 commit comments