Skip to content

Commit 8d38907

Browse files
author
Serhii Balko
committed
Merge remote-tracking branch 'origin/MC-41464' into 2.4-develop-pr56
2 parents c46d9bf + 8f6a44d commit 8d38907

File tree

2 files changed

+76
-2
lines changed

2 files changed

+76
-2
lines changed

app/code/Magento/Multishipping/Model/Cart/Controller/CartPlugin.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use Magento\Customer\Api\AddressRepositoryInterface;
1313
use Magento\Framework\App\RequestInterface;
1414
use Magento\Framework\Exception\LocalizedException;
15-
use Magento\Multishipping\Model\Checkout\Type\Multishipping\State;
1615
use Magento\Multishipping\Model\DisableMultishipping;
1716
use Magento\Quote\Api\CartRepositoryInterface;
1817
use Magento\Quote\Model\Quote;
@@ -73,7 +72,7 @@ public function beforeDispatch(Cart $subject, RequestInterface $request)
7372
{
7473
/** @var Quote $quote */
7574
$quote = $this->checkoutSession->getQuote();
76-
if ($quote->isMultipleShippingAddresses()) {
75+
if ($quote->isMultipleShippingAddresses() || $this->isDisableMultishippingRequired($request, $quote)) {
7776
$this->disableMultishipping->execute($quote);
7877
foreach ($quote->getAllShippingAddresses() as $address) {
7978
$quote->removeAddress($address->getId());
@@ -111,4 +110,18 @@ private function isVirtualItemInQuote(Quote $quote): bool
111110

112111
return false;
113112
}
113+
114+
/**
115+
* Check if we have to disable multishipping mode depends on the request action name
116+
*
117+
* We should not disable multishipping mode if we are adding a new product item to the existing quote
118+
*
119+
* @param RequestInterface $request
120+
* @param Quote $quote
121+
* @return bool
122+
*/
123+
private function isDisableMultishippingRequired(RequestInterface $request, Quote $quote): bool
124+
{
125+
return $request->getActionName() !== "add" && $quote->getIsMultiShipping();
126+
}
114127
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="StorefrontDisableMultishippingModeAfterRemoveItemOnBackToCartTest">
12+
<annotations>
13+
<features value="Multishipping"/>
14+
<stories value="Multishipping"/>
15+
<title value="Disable multishipping checkout on backing to cart after remove item"/>
16+
<description value="The cart page should display the proper subtotal after backing back to the cart from the multishipping checkout."/>
17+
<severity value="CRITICAL"/>
18+
<testCaseId value="MC-41594"/>
19+
<useCaseId value="MC-41464"/>
20+
<group value="multishipping"/>
21+
</annotations>
22+
<before>
23+
<createData entity="ApiCategory" stepKey="createCategory"/>
24+
<createData entity="_defaultProduct" stepKey="createSimpleProduct">
25+
<requiredEntity createDataKey="createCategory"/>
26+
</createData>
27+
<createData entity="Simple_US_Customer_Multiple_Addresses" stepKey="createCustomerWithMultipleAddresses"/>
28+
</before>
29+
<after>
30+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
31+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
32+
<deleteData createDataKey="createCustomerWithMultipleAddresses" stepKey="deleteCustomer"/>
33+
</after>
34+
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginAsCustomer">
35+
<argument name="Customer" value="$createCustomerWithMultipleAddresses$"/>
36+
</actionGroup>
37+
38+
<actionGroup ref="StorefrontOpenProductEntityPageActionGroup" stepKey="openSimpleProductPage">
39+
<argument name="product" value="$createSimpleProduct$"/>
40+
</actionGroup>
41+
<grabTextFrom selector="{{StorefrontProductInfoMainSection.price}}" stepKey="grabPrice"/>
42+
<actionGroup ref="StorefrontAddProductToCartActionGroup" stepKey="addSimpleProductToCart">
43+
<argument name="product" value="$createSimpleProduct$"/>
44+
<argument name="productCount" value="1"/>
45+
</actionGroup>
46+
<actionGroup ref="StorefrontAddProductToCartActionGroup" stepKey="addSimpleProductToCartAgain">
47+
<argument name="product" value="$createSimpleProduct$"/>
48+
<argument name="productCount" value="2"/>
49+
</actionGroup>
50+
51+
<actionGroup ref="ClickViewAndEditCartFromMiniCartActionGroup" stepKey="goToShoppingCartFromMinicart"/>
52+
<actionGroup ref="StorefrontGoCheckoutWithMultipleAddressesActionGroup" stepKey="goCheckoutWithMultipleAddresses"/>
53+
<actionGroup ref="StorefrontRemoveProductOnCheckoutActionGroup" stepKey="removeFirstProductItemFromMultishipping"/>
54+
<actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goBackToShoppingCartPage"/>
55+
<grabTextFrom selector="{{CheckoutCartProductSection.productSubtotalByName($createSimpleProduct.name$)}}" stepKey="grabSubtotal"/>
56+
<assertEquals stepKey="assertSubtotal" message="pass">
57+
<expectedResult type="variable">grabPrice</expectedResult>
58+
<actualResult type="variable">grabSubtotal</actualResult>
59+
</assertEquals>
60+
</test>
61+
</tests>

0 commit comments

Comments
 (0)