@@ -86,16 +86,26 @@ public function clearAddressItem($subject, $request)
86
86
$ isMultipleShippingAddressesPresent = $ quote ->isMultipleShippingAddresses ();
87
87
if ($ isMultipleShippingAddressesPresent || $ this ->isDisableMultishippingRequired ($ request , $ quote )) {
88
88
$ this ->disableMultishipping ->execute ($ quote );
89
+ $ currentShippingAddress = $ quote ->getShippingAddress ();
89
90
foreach ($ quote ->getAllShippingAddresses () as $ address ) {
91
+ if ($ address ->getId () == $ currentShippingAddress ->getId ()) {
92
+ continue ;
93
+ }
90
94
$ quote ->removeAddress ($ address ->getId ());
91
95
}
92
96
93
- $ shippingAddress = $ quote ->getShippingAddress ();
94
- $ defaultShipping = $ quote ->getCustomer ()->getDefaultShipping ();
95
- if ($ defaultShipping ) {
96
- $ defaultCustomerAddress = $ this ->addressRepository ->getById ($ defaultShipping );
97
- $ shippingAddress ->importCustomerAddressData ($ defaultCustomerAddress );
97
+ if ($ currentShippingAddress ) {
98
+ $ defaultShipping = $ currentShippingAddress ->getCustomerAddressId ();
99
+ $ quote ->addShippingAddress ($ currentShippingAddress );
100
+ } else {
101
+ $ shippingAddress = $ quote ->getShippingAddress ();
102
+ $ defaultShipping = $ quote ->getCustomer ()->getDefaultShipping ();
103
+ if ($ defaultShipping ) {
104
+ $ defaultCustomerAddress = $ this ->addressRepository ->getById ($ defaultShipping );
105
+ $ shippingAddress ->importCustomerAddressData ($ defaultCustomerAddress );
106
+ }
98
107
}
108
+
99
109
if ($ isMultipleShippingAddressesPresent ) {
100
110
$ this ->checkoutSession ->setMultiShippingAddressesFlag (true );
101
111
}
0 commit comments