Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue #18349 Fixed for 2.3: Incorrect quote_item_id saved on order items during multiple address checkout #19192

Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ private function removePlacedItemsFromQuote(array $shippingAddresses, array $pla
{
foreach ($shippingAddresses as $address) {
foreach ($address->getAllItems() as $addressItem) {
if (in_array($addressItem->getId(), $placedAddressItems)) {
if (in_array($addressItem->getQuoteItemId(), $placedAddressItems)) {
if ($addressItem->getProduct()->getIsVirtual()) {
$addressItem->isDeleted(true);
} else {
Expand Down Expand Up @@ -1232,7 +1232,7 @@ private function searchQuoteAddressId(OrderInterface $order, array $addresses):
$item = array_pop($items);
foreach ($addresses as $address) {
foreach ($address->getAllItems() as $addressItem) {
if ($addressItem->getId() == $item->getQuoteItemId()) {
if ($addressItem->getQuoteItemId() == $item->getQuoteItemId()) {
return (int)$address->getId();
}
}
Expand Down
12 changes: 12 additions & 0 deletions app/code/Magento/Quote/Model/Quote/Item/ToOrderItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public function __construct(
}

/**
* Convert quote item(quote address item) into order item.
*
* @param Item|AddressItem $item
* @param array $data
* @return OrderItemInterface
Expand All @@ -63,6 +65,16 @@ public function convert($item, $data = [])
'to_order_item',
$item
);
if ($item instanceof \Magento\Quote\Model\Quote\Address\Item) {
$orderItemData = array_merge(
$orderItemData,
$this->objectCopyService->getDataFromFieldset(
'quote_convert_address_item',
'to_order_item',
$item
)
);
}
if (!$item->getNoDiscount()) {
$data = array_merge(
$data,
Expand Down
5 changes: 5 additions & 0 deletions app/code/Magento/Quote/etc/fieldset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@
<aspect name="to_order_address" />
</field>
</fieldset>
<fieldset id="quote_convert_address_item">
<field name="quote_item_id">
<aspect name="to_order_item" />
</field>
</fieldset>
<fieldset id="quote_convert_item">
<field name="sku">
<aspect name="to_order_item" />
Expand Down