@@ -86,16 +86,26 @@ public function clearAddressItem($subject, $request)
8686 $ isMultipleShippingAddressesPresent = $ quote ->isMultipleShippingAddresses ();
8787 if ($ isMultipleShippingAddressesPresent || $ this ->isDisableMultishippingRequired ($ request , $ quote )) {
8888 $ this ->disableMultishipping ->execute ($ quote );
89+ $ currentShippingAddress = $ quote ->getShippingAddress ();
8990 foreach ($ quote ->getAllShippingAddresses () as $ address ) {
91+ if ($ address ->getId () == $ currentShippingAddress ->getId ()) {
92+ continue ;
93+ }
9094 $ quote ->removeAddress ($ address ->getId ());
9195 }
9296
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+ }
98107 }
108+
99109 if ($ isMultipleShippingAddressesPresent ) {
100110 $ this ->checkoutSession ->setMultiShippingAddressesFlag (true );
101111 }
0 commit comments