Skip to content

Commit 47fbdfe

Browse files
committed
Merge remote-tracking branch 'origin/AC-7886' into Arrows_2.4.7_Backlog_Delivery
2 parents 5d0f3a2 + d5d8649 commit 47fbdfe

File tree

4 files changed

+149
-0
lines changed

4 files changed

+149
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?xml version="1.0" encoding="UTF-8"?><!--
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
-->
7+
8+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
9+
<test name="StorefrontFreeShippingShouldNotApplyIfOtherDiscountAppliedTest">
10+
<annotations>
11+
<features value="Shipping"/>
12+
<stories value="Offline Shipping Methods"/>
13+
<title value="Free Shipping Should Not Applicable if Other Discount Reduce the Matching Amount"/>
14+
<description value="Free Shipping Should Not Applicable if Other Discount Reduce the Matching Amount"/>
15+
<severity value="CRITICAL"/>
16+
<testCaseId value="AC-7886"/>
17+
<group value="shipping"/>
18+
</annotations>
19+
<before>
20+
<!-- Create cart price rule -->
21+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
22+
<!--Create active cart price rule-->
23+
<actionGroup ref="AdminCreateCartPriceRuleActionsWithSubtotalExclTaxActionGroup" stepKey="createFreeShippingCartPriceRule">
24+
<argument name="ruleName" value="CartPriceRuleFreeShippingAppliedOnly"/>
25+
</actionGroup>
26+
<actionGroup ref="AdminCreateCartPriceRuleWithCouponCodeActionGroup" stepKey="createCartPriceRule">
27+
<argument name="ruleName" value="CartPriceRuleConditionWithCouponAppliedForSubtotalExclTax"/>
28+
<argument name="couponCode" value="CartPriceRuleConditionWithCouponAppliedForSubtotalExclTax.coupon_code"/>
29+
</actionGroup>
30+
<!-- Add simple product -->
31+
<createData entity="SimpleProduct2" stepKey="createSimpleProduct">
32+
<field key="price">100.00</field>
33+
</createData>
34+
</before>
35+
<after>
36+
<actionGroup ref="DeleteCartPriceRuleByName" stepKey="deleteFreeShippingCartPriceRule">
37+
<argument name="ruleName" value="{{CartPriceRuleFreeShippingAppliedOnly.name}}"/>
38+
</actionGroup>
39+
<actionGroup ref="DeleteCartPriceRuleByName" stepKey="deleteCartPriceRule">
40+
<argument name="ruleName" value="{{CartPriceRuleConditionWithCouponAppliedForSubtotalExclTax.name}}"/>
41+
</actionGroup>
42+
<!-- Remove simple product-->
43+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
44+
45+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
46+
</after>
47+
<!-- Add simple product to cart -->
48+
<actionGroup ref="AddSimpleProductToCartActionGroup" stepKey="addProductToCart">
49+
<argument name="product" value="$$createSimpleProduct$$"/>
50+
</actionGroup>
51+
52+
<!-- Assert that table rate value is correct for US -->
53+
<actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="openShoppingCartPage"/>
54+
<waitForElement time="30" selector="{{CheckoutCartSummarySection.estimateShippingAndTaxForm}}" stepKey="waitForEstimateShippingAndTaxForm"/>
55+
<waitForElement time="30" selector="{{CheckoutCartSummarySection.shippingMethodForm}}" stepKey="waitForShippingMethodForm"/>
56+
<conditionalClick selector="{{CheckoutCartSummarySection.estimateShippingAndTax}}" dependentSelector="{{CheckoutCartSummarySection.country}}" visible="false" stepKey="expandEstimateShippingandTax" />
57+
<see selector="{{CheckoutCartSummarySection.shippingPrice}}" userInput="$0.00" stepKey="seeFlatShippingZero"/>
58+
59+
<!-- Apply Discount Coupon to the Order -->
60+
<actionGroup ref="StorefrontShoppingCartClickApplyDiscountButtonActionGroup" stepKey="clickApplyButton"/>
61+
<actionGroup ref="StorefrontShoppingCartFillCouponCodeFieldActionGroup" stepKey="fillDiscountCodeField">
62+
<argument name="discountCode" value="{{CartPriceRuleConditionWithCouponAppliedForSubtotalExclTax.coupon_code}}"/>
63+
</actionGroup>
64+
<actionGroup ref="StorefrontShoppingCartClickApplyDiscountButtonActionGroup" stepKey="clickApplyDiscountButton"/>
65+
<actionGroup ref="AssertMessageCustomerChangeAccountInfoActionGroup" stepKey="assertSuccessMessage">
66+
<argument name="message" value='You used coupon code "{{CartPriceRuleConditionWithCouponAppliedForSubtotalExclTax.coupon_code}}".'/>
67+
</actionGroup>
68+
<waitForElement time="30" selector="{{CheckoutCartSummarySection.estimateShippingAndTaxForm}}" stepKey="waitForEstimateShippingAndTaxFormAfterCouponApplied"/>
69+
<waitForElement time="30" selector="{{CheckoutCartSummarySection.shippingMethodForm}}" stepKey="waitForShippingMethodFormAfterCouponApplied"/>
70+
<see selector="{{CheckoutCartSummarySection.shippingPrice}}" userInput="$5.00" stepKey="seeFlatShippingPrice"/>
71+
</test>
72+
</tests>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ public function collect(
222222
$total->setBaseSubtotalWithDiscount($total->getBaseSubtotal() + $total->getBaseDiscountAmount());
223223
$address->setDiscountAmount($total->getDiscountAmount());
224224
$address->setBaseDiscountAmount($total->getBaseDiscountAmount());
225+
$address->setBaseSubtotalWithDiscount($total->getBaseSubtotal() + $total->getBaseDiscountAmount());
226+
$address->setSubtotalWithDiscount($total->getSubtotal() + $total->getDiscountAmount());
225227
return $this;
226228
}
227229

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminCreateCartPriceRuleActionsWithSubtotalExclTaxActionGroup" extends="AdminCreateCartPriceRuleActionGroup">
12+
<annotations>
13+
<description>EXTENDS: AdminCreateCartPriceRuleActionGroup. Removes 'fillDiscountAmount'. Adds sub total excl tax conditions for free shipping to a Cart Price Rule.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="ruleName"/>
17+
</arguments>
18+
<remove keyForRemoval="fillDiscountAmount"/>
19+
<!-- Expand the conditions section -->
20+
<grabTextFrom selector="{{AdminCartPriceRulesFormSection.ruleName}}" after="fillRuleName" stepKey="getSubtotalRule"/>
21+
<click selector="{{AdminCartPriceRulesFormSection.conditionsHeader}}" stepKey="openConditionsSection" after="selectActionType"/>
22+
<click selector="#conditions__1__children>li:nth-child(1)>span:nth-child(1) a" after="openConditionsSection" stepKey="addFirstCondition"/>
23+
<selectOption selector="{{AdminCartPriceRulesFormSection.conditionSelect}}" userInput="{{ruleName.condition1}}" after="addFirstCondition" stepKey="selectCondition1"/>
24+
<waitForPageLoad after="selectCondition1" stepKey="waitForConditionLoad"/>
25+
<click selector="{{AdminCartPriceRulesFormSection.condition(ruleName.ruleToChange1)}}" after="waitForConditionLoad" stepKey="clickToChooseOption"/>
26+
<selectOption selector="{{AdminCartPriceRulesFormSection.conditionsOperator}}" userInput="{{ruleName.rule1}}" after="clickToChooseOption" stepKey="setOperatorType"/>
27+
<click selector="{{AdminCartPriceRulesFormSection.targetEllipsis}}" after="setOperatorType" stepKey="clickEllipsis"/>
28+
<fillField selector="{{AdminCartPriceRulesFormSection.ruleFieldByIndex('1--1')}}" userInput="{{ruleName.subtotal}}" after="clickEllipsis" stepKey="fillSubtotalParameter"/>
29+
<click selector="{{AdminCartPriceRulesFormSection.discardSubsequentRules}}" after="fillSubtotalParameter" stepKey="clickDiscardSubsequentRules"/>
30+
<selectOption selector="{{AdminCartPriceRulesFormSection.freeShipping}}" userInput="{{ruleName.simple_free_shipping}}" after="clickDiscardSubsequentRules" stepKey="selectForMatchingItemsOnly"/>
31+
</actionGroup>
32+
</actionGroups>

app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleData.xml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,49 @@
357357
<data key="defaultRuleLabelAllStoreViews">Free Shipping in conditions</data>
358358
<data key="defaultStoreView">Free Shipping in conditions</data>
359359
</entity>
360+
<entity name="CartPriceRuleFreeShippingAppliedOnly">
361+
<data key="name" unique="suffix">Cart Price Rule For FreeShipping Only</data>
362+
<data key="description">Description for Cart Price Rule</data>
363+
<data key="is_active">Yes</data>
364+
<data key="websites">Main Website</data>
365+
<data key="customerGroups">NOT LOGGED IN</data>
366+
<data key="coupon_type">No Coupon</data>
367+
<data key="simple_action">Percent of product price discount</data>
368+
<data key="discount_amount">0</data>
369+
<data key="maximumQtyDiscount">0</data>
370+
<data key="discount_step">0</data>
371+
<data key="apply">Percent of product price discount</data>
372+
<data key="condition1">Subtotal (Excl. Tax)</data>
373+
<data key="rule1">equals or greater than</data>
374+
<data key="subtotal">100</data>
375+
<data key="ruleToChange1">is</data>
376+
<data key="apply_to_shipping">0</data>
377+
<data key="stop_rules_processing">false</data>
378+
<data key="simple_free_shipping">For matching items only</data>
379+
<data key="defaultRuleLabelAllStoreViews">Free Shipping in conditions</data>
380+
<data key="defaultStoreView">Free Shipping in conditions</data>
381+
</entity>
382+
<entity name="CartPriceRuleConditionWithCouponAppliedForSubtotalExclTax">
383+
<data key="name" unique="suffix">Cart Price Rule For Rule Condition</data>
384+
<data key="description">Description for Cart Price Rule</data>
385+
<data key="is_active">Yes</data>
386+
<data key="websites">Main Website</data>
387+
<data key="customerGroups">NOT LOGGED IN</data>
388+
<data key="coupon_type">Specific Coupon</data>
389+
<data key="coupon_code" unique="suffix">123-abc-ABC-987</data>
390+
<data key="uses_per_coupon">13</data>
391+
<data key="uses_per_customer">63</data>
392+
<data key="simple_action">Percent of product price discount</data>
393+
<data key="discount_amount">10</data>
394+
<data key="maximumQtyDiscount">0</data>
395+
<data key="discount_step">0</data>
396+
<data key="apply_to_shipping">0</data>
397+
<data key="simple_free_shipping">No</data>
398+
<data key="stop_rules_processing">false</data>
399+
<data key="apply">Percent of product price discount</data>
400+
<data key="defaultRuleLabelAllStoreViews">Free Shipping in Rule conditions</data>
401+
<data key="defaultStoreView">Free Shipping in Rule conditions</data>
402+
</entity>
360403
<entity name="CartPriceRuleConditionAppliedForSubtotal">
361404
<data key="name" unique="suffix">Cart Price Rule For Rule Condition</data>
362405
<data key="description">Description for Cart Price Rule</data>

0 commit comments

Comments
 (0)