Skip to content

Commit 35fb445

Browse files
committed
ACP2E-3646: Addresses selection is not saved when we "Check Out with Multiple Addresses"
1 parent f309978 commit 35fb445

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

app/code/Magento/Multishipping/Model/Cart/MultishippingClearItemAddress.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,15 @@ protected function _init()
296296
*/
297297
$addresses = $quote->getAllAddresses();
298298
foreach ($addresses as $address) {
299+
if ($address->getAllItems()) {
300+
$defaultShippingId = $address->getCustomerAddressId();
301+
}
299302
$quote->removeAddress($address->getId());
300303
}
301304

302-
$defaultShippingId = $this->getCustomerDefaultShippingAddress();
305+
if (!$defaultShippingId) {
306+
$defaultShippingId = $this->getCustomerDefaultShippingAddress();
307+
}
303308
if ($defaultShippingId) {
304309
$quote->getShippingAddress()->importCustomerAddressData(
305310
$this->addressRepository->getById($defaultShippingId)

0 commit comments

Comments
 (0)