Skip to content

Commit 4c7a2b1

Browse files
committed
ACP2E-693: Addresses disappear from multi-shipping checkout after removing several items.
1 parent d8bb37d commit 4c7a2b1

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

app/code/Magento/Multishipping/Test/Mftf/Test/StoreFrontRemoveItemFromMultishipmentCartTest.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,18 @@
6868
</actionGroup>
6969
<!-- Save updated addresses -->
7070
<actionGroup ref="StorefrontMultiShippingSaveAddressActionGroup" stepKey="saveThreeDifferentAddresses"/>
71+
<!-- Verify there are 3 items available on cart page -->
72+
<seeNumberOfElements userInput="3" selector="a.action.delete" stepKey="seeThreeItems"/>
7173
<!-- Remove first simple item from cart -->
7274
<actionGroup ref="StorefrontRemoveProductOnCheckoutActionGroup" stepKey="removeFirstItemFromCart"/>
7375
<waitForPageLoad time="30" stepKey="waitForCartSummaryPageToLoadAfterRemovalOfFirstItem"/>
76+
<!-- Verify there are 2 items still available after removal of first -->
77+
<seeNumberOfElements userInput="2" selector="a.action.delete" stepKey="seeTwoItems"/>
7478
<!-- Remove second simple item from cart -->
7579
<actionGroup ref="StorefrontRemoveProductOnCheckoutActionGroup" stepKey="removeSecondItemFromCart"/>
7680
<waitForPageLoad time="30" stepKey="waitForCartSummaryPageToLoadAfterRemovalOfSecondItem"/>
81+
<!-- Verify there are 1 items still available after removal of second -->
82+
<seeNumberOfElements userInput="1" selector="a.action.delete" stepKey="seeOneItems"/>
7783
<!-- Remove second simple item from cart -->
7884
<actionGroup ref="StorefrontRemoveProductOnCheckoutActionGroup" stepKey="removeThirdItemFromCart"/>
7985
<waitForPageLoad time="30" stepKey="waitForCartSummaryPageToLoadAfterRemovalOfTestItem"/>

app/code/Magento/Quote/Model/Quote.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2544,12 +2544,13 @@ public function getShippingAddressesItems()
25442544
if ($item->getQty() > 1) {
25452545
//DB table `quote_item` qty value can not be set to 1, if having more than 1 child references
25462546
//in table `quote_address_item`.
2547-
if (count($this->getQuoteShippingAddressItemsByQuoteItemId($item->getItemId())) > 1) {
2547+
if ($item->getItemId() !== null
2548+
&& count($this->getQuoteShippingAddressItemsByQuoteItemId($item->getItemId())) > 1) {
25482549
continue;
25492550
}
25502551

25512552
for ($itemIndex = 0, $itemQty = $item->getQty(); $itemIndex < $itemQty; $itemIndex++) {
2552-
if ($itemIndex == 0) {
2553+
if ($itemIndex === 0) {
25532554
$addressItem = $item;
25542555
} else {
25552556
$addressItem = clone $item;
@@ -2679,10 +2680,7 @@ private function getQuoteShippingAddressItemsByQuoteItemId($itemId = null): arra
26792680
$addresses = $this->getAllShippingAddresses();
26802681
foreach ($addresses as $address) {
26812682
foreach ($address->getAllItems() as $item) {
2682-
if ($item->getParentItemId()) {
2683-
continue;
2684-
}
2685-
if ($item->getProduct()->getIsVirtual()) {
2683+
if ($item->getParentItemId() || $item->getProduct()->getIsVirtual()) {
26862684
continue;
26872685
}
26882686
if ($item->getQuoteItemId() === $itemId) {

0 commit comments

Comments
 (0)