Skip to content

Commit ee63e45

Browse files
AC-3652::Mini cart subtotal gets doubled when product deleted from the cart during multi shipping.
1 parent 4048f18 commit ee63e45

File tree

3 files changed

+100
-3
lines changed

3 files changed

+100
-3
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\Multishipping\Model\Cart\Controller;
99

1010
use Magento\Checkout\Controller\Sidebar\UpdateItemQty;
11+
use Magento\Framework\App\Action\HttpPostActionInterface;
1112
use Magento\Framework\App\RequestInterface;
1213
use Magento\Framework\Exception\LocalizedException;
1314
use Magento\Multishipping\Model\Cart\MultishippingClearItemAddress;
@@ -34,13 +35,13 @@ public function __construct(
3435
/**
3536
* Cleans shipping addresses and item assignments after MultiShipping flow
3637
*
37-
* @param UpdateItemQty $subject
38+
* @param HttpPostActionInterface $subject
3839
* @param RequestInterface $request
3940
* @return void
4041
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
4142
* @throws LocalizedException
4243
*/
43-
public function beforeDispatch(UpdateItemQty $subject, RequestInterface $request)
44+
public function beforeDispatch(HttpPostActionInterface $subject, RequestInterface $request)
4445
{
4546
$this->multishippingClearItemAddress->clearAddressItem($subject, $request);
4647
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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="StorefrontCheckoutMiniCartSubtotalMatchesAfterRemoveOneProductFromCartTest">
12+
<annotations>
13+
<features value="Multishipping"/>
14+
<stories value="Multiple Shipping"/>
15+
<title value="Check mini shopping cart Subtotal Price matches with the View Cart subtotal price after remove one product from cart"/>
16+
<description value="Verify mini shopping cart Subtotal Price matches with the View Cart subtotal price after remove one product from cart"/>
17+
<severity value="MAJOR"/>
18+
<testCaseId value="AC-3652"/>
19+
<useCaseId value="AC-3652"/>
20+
<group value="Multishipment"/>
21+
</annotations>
22+
<before>
23+
<!-- Login as Admin -->
24+
<actionGroup ref="AdminLoginActionGroup" stepKey="login"/>
25+
<!-- Create simple products -->
26+
<createData entity="SimpleSubCategory" stepKey="createCategory"/>
27+
<createData entity="SimpleProduct" stepKey="firstProduct">
28+
<requiredEntity createDataKey="createCategory"/>
29+
</createData>
30+
<createData entity="SimpleProduct" stepKey="secondProduct">
31+
<requiredEntity createDataKey="createCategory"/>
32+
</createData>
33+
<createData entity="Customer_US_UK_DE" stepKey="createCustomerWithMultipleAddresses"/>
34+
</before>
35+
<after>
36+
<!-- Delete created data -->
37+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
38+
<deleteData createDataKey="firstProduct" stepKey="deleteFirstProduct"/>
39+
<deleteData createDataKey="secondProduct" stepKey="deleteSecondProduct"/>
40+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
41+
<deleteData createDataKey="createCustomerWithMultipleAddresses" stepKey="deleteCustomer"/>
42+
</after>
43+
<!-- Login to the Storefront as created customer -->
44+
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginAsCustomer">
45+
<argument name="Customer" value="$$createCustomerWithMultipleAddresses$$"/>
46+
</actionGroup>
47+
<!-- Open the first product page -->
48+
<actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="goToFirstProductPage">
49+
<argument name="productUrl" value="$$firstProduct.custom_attributes[url_key]$$"/>
50+
</actionGroup>
51+
<!-- Add the first product to the Shopping Cart -->
52+
<actionGroup ref="AddProductWithQtyToCartFromStorefrontProductPageActionGroup" stepKey="addFirstProductToCart">
53+
<argument name="productName" value="$$firstProduct.name$$"/>
54+
<argument name="productQty" value="1"/>
55+
</actionGroup>
56+
<!-- Open the second product page -->
57+
<actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="goToSecondProductPage">
58+
<argument name="productUrl" value="$$secondProduct.custom_attributes[url_key]$$"/>
59+
</actionGroup>
60+
<!-- Add the second product to the Shopping Cart -->
61+
<actionGroup ref="AddProductWithQtyToCartFromStorefrontProductPageActionGroup" stepKey="addSecondProductToCart">
62+
<argument name="productName" value="$$secondProduct.name$$"/>
63+
<argument name="productQty" value="1"/>
64+
</actionGroup>
65+
<!--Go to Cart -->
66+
<actionGroup ref="StorefrontOpenCartFromMinicartActionGroup" stepKey="openCart"/>
67+
<!--Check Out with Multiple Addresses -->
68+
<actionGroup ref="StorefrontCheckoutWithMultipleAddressesActionGroup" stepKey="checkoutWithMultipleAddresses"/>
69+
<!-- Select different addresses and click 'Go to Shipping Information' -->
70+
<actionGroup ref="StorefrontSelectAddressActionGroup" stepKey="selectFirstAddress">
71+
<argument name="sequenceNumber" value="1"/>
72+
<argument name="option" value="John Doe, 368 Broadway St. 113, New York, New York 10001, United States"/>
73+
</actionGroup>
74+
<actionGroup ref="StorefrontSelectAddressActionGroup" stepKey="selectSecondAddress">
75+
<argument name="sequenceNumber" value="2"/>
76+
<argument name="option" value="John Doe, Augsburger Strabe 41, Berlin, 10789, Germany"/>
77+
</actionGroup>
78+
<actionGroup ref="StorefrontSaveAddressActionGroup" stepKey="saveAddresses"/>
79+
<!-- Open the second product page -->
80+
<actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="goToSecondProductPage1">
81+
<argument name="productUrl" value="$$secondProduct.custom_attributes[url_key]$$"/>
82+
</actionGroup>
83+
<actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="openMiniCart"/>
84+
<click selector="{{StorefrontMinicartSection.deleteMiniCartItem}}" stepKey="deleteMiniCartItem"/>
85+
<waitForElementVisible selector="{{StoreFrontRemoveItemModalSection.message}}" stepKey="waitFortheConfirmationModal"/>
86+
<see selector="{{StoreFrontRemoveItemModalSection.message}}" userInput="Are you sure you would like to remove this item from the shopping cart?" stepKey="seeDeleteConfirmationMessage"/>
87+
<click selector="{{StoreFrontRemoveItemModalSection.ok}}" stepKey="confirmDelete"/>
88+
<waitForPageLoad stepKey="waitForDeleteToFinish"/>
89+
<actionGroup ref="AssertStorefrontMiniCartSubtotalActionGroup" stepKey="assertSubtotal">
90+
<argument name="subtotal" value="$123.00"/>
91+
</actionGroup>
92+
</test>
93+
</tests>

app/code/Magento/Multishipping/etc/frontend/di.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@
4646
<plugin name="multishipping_clear_addresses" type="Magento\Multishipping\Model\Cart\Controller\CartPlugin" sortOrder="50" />
4747
</type>
4848
<type name="Magento\Checkout\Controller\Sidebar\UpdateItemQty">
49-
<plugin name="multishipping_clear_addresses" type="Magento\Multishipping\Model\Cart\Controller\MiniCartPlugin" sortOrder="50" />
49+
<plugin name="multishipping_clear_addresses_before_update_qty" type="Magento\Multishipping\Model\Cart\Controller\MiniCartPlugin" sortOrder="50" />
50+
</type>
51+
<type name="Magento\Checkout\Controller\Sidebar\RemoveItem">
52+
<plugin name="multishipping_clear_addresses_before_remove_item" type="Magento\Multishipping\Model\Cart\Controller\MiniCartPlugin" sortOrder="50" />
5053
</type>
5154
<type name="Magento\Quote\Model\Quote">
5255
<plugin name="multishipping_reset_shipping_assigment" type="Magento\Multishipping\Plugin\ResetShippingAssigment"/>

0 commit comments

Comments
 (0)