Skip to content

Commit d334838

Browse files
MC-19105: One item purchased turns into two items on reorder (Multi-shipping)
1 parent 01b5c9d commit d334838

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

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

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
* @SuppressWarnings(PHPMD.TooManyFields)
2424
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
2525
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
26+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
2627
* @since 100.0.2
2728
*/
2829
class Multishipping extends \Magento\Framework\DataObject
@@ -526,6 +527,7 @@ protected function _addShippingItem($quoteItemId, $data)
526527
$quoteItem->setQty($quoteItem->getMultishippingQty());
527528
try {
528529
$address = $this->addressRepository->getById($addressId);
530+
// phpcs:ignore Magento2.CodeAnalysis.EmptyBlock
529531
} catch (\Exception $e) {
530532
}
531533
if (isset($address)) {
@@ -565,6 +567,7 @@ public function updateQuoteCustomerShippingAddress($addressId)
565567
}
566568
try {
567569
$address = $this->addressRepository->getById($addressId);
570+
// phpcs:ignore Magento2.CodeAnalysis.EmptyBlock
568571
} catch (\Exception $e) {
569572
//
570573
}
@@ -592,6 +595,7 @@ public function setQuoteCustomerBillingAddress($addressId)
592595
}
593596
try {
594597
$address = $this->addressRepository->getById($addressId);
598+
// phpcs:ignore Magento2.CodeAnalysis.EmptyBlock
595599
} catch (\Exception $e) {
596600
//
597601
}
@@ -825,7 +829,7 @@ public function createOrders()
825829
if ($order->getCanSendNewEmailFlag()) {
826830
$this->orderSender->send($order);
827831
}
828-
$placedAddressItems = array_merge($placedAddressItems, $this->getQuoteAddressItems($order));
832+
$placedAddressItems = $this->getPlacedAddressItems($order);
829833
}
830834

831835
$addressErrors = [];
@@ -1090,10 +1094,14 @@ public function getCustomer()
10901094
*/
10911095
protected function isAddressIdApplicable($addressId)
10921096
{
1093-
$applicableAddressIds = array_map(function ($address) {
1094-
/** @var \Magento\Customer\Api\Data\AddressInterface $address */
1095-
return $address->getId();
1096-
}, $this->getCustomer()->getAddresses());
1097+
$applicableAddressIds = array_map(
1098+
function ($address) {
1099+
/** @var \Magento\Customer\Api\Data\AddressInterface $address */
1100+
return $address->getId();
1101+
},
1102+
$this->getCustomer()->getAddresses()
1103+
);
1104+
10971105
return !is_numeric($addressId) || in_array($addressId, $applicableAddressIds);
10981106
}
10991107

@@ -1279,4 +1287,20 @@ private function getQuoteAddressItems(OrderInterface $order): array
12791287

12801288
return $placedAddressItems;
12811289
}
1290+
1291+
/**
1292+
* Returns placed address items
1293+
*
1294+
* @param OrderInterface $order
1295+
* @return array
1296+
*/
1297+
private function getPlacedAddressItems(OrderInterface $order): array
1298+
{
1299+
$placedAddressItems = [];
1300+
foreach ($this->getQuoteAddressItems($order) as $key => $quoteAddressItem) {
1301+
$placedAddressItems[$key] = $quoteAddressItem;
1302+
}
1303+
1304+
return $placedAddressItems;
1305+
}
12821306
}

0 commit comments

Comments
 (0)