Skip to content

Commit bd53750

Browse files
committed
MC-21738: Cart Price Rules not working for Multishipping
- MFTF tests
1 parent 6f1c7e3 commit bd53750

File tree

4 files changed

+88
-1
lines changed

4 files changed

+88
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,9 @@ public function setPaymentMethod($payment)
662662
$quote->getPayment()->importData($payment);
663663
// shipping totals may be affected by payment method
664664
if (!$quote->isVirtual() && $quote->getShippingAddress()) {
665-
$quote->getShippingAddress()->setCollectShippingRates(true);
665+
foreach ($quote->getAllShippingAddresses() as $shippingAddress) {
666+
$shippingAddress->setCollectShippingRates(true);
667+
}
666668
$quote->setTotalsCollectedFlag(false)->collectTotals();
667669
}
668670
$this->quoteRepository->save($quote);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
11+
<entity name="CartPriceRuleConditionForSubtotalForMultiShipping" extends="CartPriceRuleConditionAppliedForSubtotal">
12+
<data key="apply">Percent of product price discount</data>
13+
<data key="customerGroups">'NOT LOGGED IN', 'General', 'Wholesale', 'Retailer'</data>
14+
<data key="subtotal">50</data>
15+
<data key="apply_to_shipping">1</data>
16+
<data key="simple_free_shipping">For matching items only</data>
17+
<data key="condition1">Subtotal</data>
18+
<data key="condition2">Shipping Method</data>
19+
<data key="rule1">equals or greater than</data>
20+
<data key="shippingMethod">[flatrate] Fixed</data>
21+
<data key="ruleToChange1">is</data>
22+
</entity>
23+
</entities>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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="StorefrontCheckingWithCartPriceRuleMatchingSubtotalForMultiShipmentTest" extends="StoreFrontCheckingWithMultishipmentTest">
12+
<annotations>
13+
<features value="Multi shipment and Cart Price Rule"/>
14+
<stories value="Checking cart price rule for multi shipment with multiple shipment addresses on front end order page"/>
15+
<title value="Checking sub total amount and free shipping is applied with multiple shipment addresses on front end order page"/>
16+
<description value="Cart Price Rules not working and free shipping not applied for Multi shipping "/>
17+
<severity value="MAJOR"/>
18+
<testCaseId value="MC-21738"/>
19+
<group value="Multishipment"/>
20+
<group value="SalesRule"/>
21+
</annotations>
22+
<before>
23+
<magentoCLI command="config:set multishipping/options/checkout_multiple 1" stepKey="allowShippingToMultipleAddresses"/>
24+
</before>
25+
<after>
26+
<magentoCLI command="config:set multishipping/options/checkout_multiple 0" stepKey="disableShippingToMultipleAddresses"/>
27+
</after>
28+
<actionGroup ref="AdminCreateCartPriceRuleActionsWithSubtotalActionGroup" before="goToProduct1" stepKey="createSubtotalCartPriceRuleActionsSection">
29+
<argument name="ruleName" value="CartPriceRuleConditionForSubtotalForMultiShipping"/>
30+
</actionGroup>
31+
<actionGroup ref="DeleteCartPriceRuleByName" after="placeOrder" stepKey="deleteCreatedCartPriceRule">
32+
<argument name="ruleName" value="{$getSubtotalRuleCreateSubtotalCartPriceRuleActionsSection}"/>
33+
</actionGroup>
34+
</test>
35+
</tests>

app/code/Magento/SalesRule/Test/Mftf/ActionGroup/AdminCreateCartPriceRuleActionGroup.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,33 @@
105105
<waitForElementVisible selector="{{AdminCartPriceRulesFormSection.categoryCheckbox(categoryName)}}" stepKey="waitForCategoryVisible" after="openChooser"/>
106106
<checkOption selector="{{AdminCartPriceRulesFormSection.categoryCheckbox(categoryName)}}" stepKey="checkCategoryName" after="waitForCategoryVisible"/>
107107
</actionGroup>
108+
<actionGroup name="AdminCreateCartPriceRuleActionsWithSubtotalActionGroup" extends="AdminCreateCartPriceRuleActionGroup">
109+
<annotations>
110+
<description>EXTENDS: AdminCreateCartPriceRuleActionGroup. Removes 'fillDiscountAmount'. Adds sub total conditions for free shipping to a Cart Price Rule.</description>
111+
</annotations>
112+
<arguments>
113+
<argument name="ruleName"/>
114+
</arguments>
115+
<remove keyForRemoval="fillDiscountAmount"/>
116+
<!-- Expand the conditions section -->
117+
<grabTextFrom selector="{{AdminCartPriceRulesFormSection.ruleName}}" after="fillRuleName" stepKey="getSubtotalRule"/>
118+
<click selector="{{AdminCartPriceRulesFormSection.conditionsHeader}}" stepKey="openConditionsSection" after="selectActionType"/>
119+
<click selector="{{AdminCartPriceRulesFormSection.addCondition('1')}}" after="openConditionsSection" stepKey="addFirstCondition"/>
120+
<selectOption selector="{{AdminCartPriceRulesFormSection.conditionSelect}}" userInput="{{ruleName.condition1}}" after="addFirstCondition" stepKey="selectCondition1"/>
121+
<waitForPageLoad after="selectCondition1" stepKey="waitForConditionLoad"/>
122+
<click selector="{{AdminCartPriceRulesFormSection.condition(ruleName.ruleToChange1)}}" after="waitForConditionLoad" stepKey="clickToChooseOption"/>
123+
<selectOption selector="{{AdminCartPriceRulesFormSection.conditionsOperator}}" userInput="{{ruleName.rule1}}" after="clickToChooseOption" stepKey="setOperatorType"/>
124+
<click selector="{{AdminCartPriceRulesFormSection.targetEllipsis}}" after="setOperatorType" stepKey="clickEllipsis"/>
125+
<fillField selector="{{AdminCartPriceRulesFormSection.ruleFieldByIndex('1--1')}}" userInput="{{ruleName.subtotal}}" after="clickEllipsis" stepKey="fillSubtotalParameter"/>
126+
<click selector="{{AdminCartPriceRulesFormSection.addNewCondition('1')}}" after="fillSubtotalParameter" stepKey="clickOnTheAddNewCondition"/>
127+
<selectOption selector="{{AdminCartPriceRulesFormSection.conditionSelectDropdown('1')}}" userInput="{{ruleName.condition2}}" after="clickOnTheAddNewCondition" stepKey="selectSecondCondition"/>
128+
<waitForPageLoad after="selectSecondCondition" stepKey="waitForConditionLoad2"/>
129+
<click selector="{{AdminCartPriceRulesFormSection.targetEllipsis}}" after="waitForConditionLoad2" stepKey="clickEllipsis2"/>
130+
<selectOption selector="{{AdminCartPriceRulesFormSection.ruleFieldByIndex('1--2')}}" userInput="{{ruleName.shippingMethod}}" after="clickEllipsis2" stepKey="selectShippingMethod"/>
131+
<click selector="{{AdminCartPriceRulesFormSection.applyToShippingAmount}}" after="selectShippingMethod" stepKey="clickApplyToShipping"/>
132+
<click selector="{{AdminCartPriceRulesFormSection.discardSubsequentRules}}" after="clickApplyToShipping" stepKey="clickDiscardSubsequentRules"/>
133+
<selectOption selector="{{AdminCartPriceRulesFormSection.freeShipping}}" userInput="{{ruleName.simple_free_shipping}}" after="clickDiscardSubsequentRules" stepKey="selectForMatchingItemsOnly"/>
134+
</actionGroup>
108135
<actionGroup name="AdminCreateMultiWebsiteCartPriceRuleActionGroup" extends="AdminCreateCartPriceRuleActionGroup">
109136
<annotations>
110137
<description>EXTENDS: AdminCreateCartPriceRuleActionGroup. Removes 'clickSaveButton' for the next data changing. Assign cart price rule to 2 websites instead of 1.</description>

0 commit comments

Comments
 (0)