Skip to content

Commit e040e1a

Browse files
committed
Merge branch 'ACP2E-2763' of https://github.com/adobe-commerce-tier-4/magento2ce into 2.4-develop
2 parents 98846c7 + 0a77239 commit e040e1a

File tree

6 files changed

+195
-5
lines changed

6 files changed

+195
-5
lines changed

app/code/Magento/OfflineShipping/Model/Carrier/Tablerate.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,6 @@ public function collectRates(RateRequest $request)
151151
$freeWeight += (int) $item->getWeight();
152152
}
153153
}
154-
155-
$request->setPackageValue($request->getPackageValue() - $freePackageValue);
156-
$request->setPackageValueWithDiscount($request->getPackageValueWithDiscount() - $freePackageValue);
157154
}
158155

159156
if ($freeWeight > 0) {

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,25 @@
379379
<data key="defaultRuleLabelAllStoreViews">Free Shipping in conditions</data>
380380
<data key="defaultStoreView">Free Shipping in conditions</data>
381381
</entity>
382+
<entity name="CartPriceRuleFreeShippingWithCouponAppliedOnly">
383+
<data key="name" unique="suffix">Cart Price Rule For Tree Shipping With Coupon</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">FreeShipping</data>
390+
<data key="simple_action">Fixed amount discount</data>
391+
<data key="discount_amount">50</data>
392+
<data key="maximumQtyDiscount">0</data>
393+
<data key="discount_step">0</data>
394+
<data key="apply_to_shipping">0</data>
395+
<data key="simple_free_shipping">For shipment with matching items</data>
396+
<data key="stop_rules_processing">false</data>
397+
<data key="apply">Percent of product price discount</data>
398+
<data key="defaultRuleLabelAllStoreViews">Free Shipping Rule</data>
399+
<data key="defaultStoreView">Free Shipping Rule</data>
400+
</entity>
382401
<entity name="CartPriceRuleConditionWithCouponAppliedForSubtotalExclTax">
383402
<data key="name" unique="suffix">Cart Price Rule For Rule Condition</data>
384403
<data key="description">Description for Cart Price Rule</data>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/************************************************************************
4+
*
5+
* Copyright 2024 Adobe
6+
* All Rights Reserved.
7+
*
8+
* NOTICE: All information contained herein is, and remains
9+
* the property of Adobe and its suppliers, if any. The intellectual
10+
* and technical concepts contained herein are proprietary to Adobe
11+
* and its suppliers and are protected by all applicable intellectual
12+
* property laws, including trade secret and copyright laws.
13+
* Dissemination of this information or reproduction of this material
14+
* is strictly forbidden unless prior written permission is obtained
15+
* from Adobe.
16+
* ************************************************************************
17+
*/
18+
-->
19+
20+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
22+
<!-- Enable/Disable Table Rates shipping method -->
23+
<actionGroup name="AdminChangeTableRatesShippingMethodConditionActionGroup">
24+
<arguments>
25+
<argument name="condition" type="string" defaultValue="{{TableRateShippingMethodConfig.package_value_with_discount}}"/>
26+
</arguments>
27+
<conditionalClick selector="{{AdminShippingMethodTableRatesSection.carriersTableRateTab}}" dependentSelector="{{AdminShippingMethodTableRatesSection.carriersTableRateActive}}" visible="false" stepKey="expandTab"/>
28+
<uncheckOption selector="{{AdminShippingMethodTableRatesSection.carriersTableRateConditionName}}" stepKey="disableUseDefaultCondition"/>
29+
<selectOption selector="{{AdminShippingMethodTableRatesSection.condition}}" userInput="{{condition}}" stepKey="setCondition"/>
30+
</actionGroup>
31+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/************************************************************************
4+
*
5+
* Copyright 2024 Adobe
6+
* All Rights Reserved.
7+
*
8+
* NOTICE: All information contained herein is, and remains
9+
* the property of Adobe and its suppliers, if any. The intellectual
10+
* and technical concepts contained herein are proprietary to Adobe
11+
* and its suppliers and are protected by all applicable intellectual
12+
* property laws, including trade secret and copyright laws.
13+
* Dissemination of this information or reproduction of this material
14+
* is strictly forbidden unless prior written permission is obtained
15+
* from Adobe.
16+
* ************************************************************************
17+
*/
18+
-->
19+
20+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
22+
<test name="StorefrontAssertShippingPricesPresentWithFreeShippingAfterApplyingCartRuleTest">
23+
<annotations>
24+
<features value="Shipping"/>
25+
<stories value="Cart price rules"/>
26+
<title value="Assert that table rate shipping price will be correct after cart price rule for free shipping applied"/>
27+
<description value="Table rate price should be displayed correctly on checkout after applied free shipment cart price rule"/>
28+
<severity value="AVERAGE"/>
29+
<testCaseId value="AC-11402"/>
30+
<useCaseId value="ACP2E-2763"/>
31+
<group value="shipping"/>
32+
<group value="SalesRule"/>
33+
<group value="cloud"/>
34+
</annotations>
35+
<before>
36+
<createData entity="ApiSimpleProductWithCustomPrice" stepKey="createProduct"/>
37+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
38+
<!-- Enable free shipping method -->
39+
<createData entity="FreeShippinMethodConfig" stepKey="enableFreeShippingMethod"/>
40+
<createData entity="setFreeShippingSubtotal" stepKey="setFreeShippingSubtotal"/>
41+
42+
<!-- Turn on and configure table rates shipping method -->
43+
<actionGroup ref="AdminOpenShippingMethodsConfigPageActionGroup" stepKey="openShippingMethodConfigPage"/>
44+
<actionGroup ref="AdminSwitchWebsiteActionGroup" stepKey="switchDefaultWebsite">
45+
<argument name="website" value="_defaultWebsite"/>
46+
</actionGroup>
47+
<actionGroup ref="AdminChangeTableRatesShippingMethodStatusActionGroup" stepKey="enableTableRatesShippingMethodForDefaultWebsite">
48+
<argument name="status" value="1"/>
49+
</actionGroup>
50+
<actionGroup ref="AdminChangeTableRatesShippingMethodConditionActionGroup" stepKey="selectPriceVsDestinationCondition">
51+
<argument name="condition" value="{{TableRateShippingMethodConfig.package_value_with_discount}}"/>
52+
</actionGroup>
53+
<actionGroup ref="AdminImportFileTableRatesShippingMethodActionGroup" stepKey="importCSVFile">
54+
<argument name="file" value="price_tablerates.csv"/>
55+
</actionGroup>
56+
<actionGroup ref="AdminSaveConfigActionGroup" stepKey="saveConfig"/>
57+
58+
<!-- Create cart price rule for free shipping -->
59+
<actionGroup ref="AdminCartPriceRuleDeleteAllActionGroup" stepKey="deleteAllExistingCartPriceRules"/>
60+
61+
<actionGroup ref="AdminOpenNewCartPriceRuleFormPageActionGroup" stepKey="createCartPriceRule"/>
62+
<actionGroup ref="AdminCartPriceRuleFillMainInfoActionGroup" stepKey="fillCartPriceRuleMainInfo">
63+
<argument name="name" value="{{CartPriceRuleFreeShippingWithCouponAppliedOnly.name}}"/>
64+
<argument name="description" value="{{CartPriceRuleFreeShippingWithCouponAppliedOnly.description}}"/>
65+
</actionGroup>
66+
<actionGroup ref="AdminCartPriceRuleFillCouponInfoActionGroup" stepKey="fillCartPriceRuleCouponInfo"/>
67+
<actionGroup ref="AdminCreateCartPriceRuleActionsSectionDiscountFieldsActionGroup" stepKey="fillCartPriceRuleActionsSection">
68+
<argument name="rule" value="CartPriceRuleFreeShippingWithCouponAppliedOnly"/>
69+
</actionGroup>
70+
<actionGroup ref="AdminCreateCartPriceRuleActionsSectionFreeShippingActionGroup" stepKey="fillCartPriceRuleFreeShippingActionsSection">
71+
<argument name="freeShippingOption" value="{{CartPriceRuleFreeShippingWithCouponAppliedOnly.simple_free_shipping}}"/>
72+
</actionGroup>
73+
<actionGroup ref="AdminCartPriceRuleSaveActionGroup" stepKey="saveCartPriceRule"/>
74+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutAsAdmin"/>
75+
</before>
76+
<after>
77+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin2"/>
78+
79+
<!-- Delete product -->
80+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
81+
82+
<!-- Delete cart price rule for free shipping -->
83+
<actionGroup ref="AdminCartPriceRuleDeleteAllActionGroup" stepKey="deleteAllCartPriceRules"/>
84+
85+
<!-- Disable free shipping method -->
86+
<actionGroup ref="AdminOpenShippingMethodsConfigPageActionGroup" stepKey="openShippingMethodConfigPage2"/>
87+
<createData entity="FreeShippinMethodDefault" stepKey="disableFreeShippingMethod"/>
88+
<createData entity="setFreeShippingSubtotalToDefault" stepKey="setFreeShippingSubtotalToDefault"/>
89+
90+
<!-- Turn off table rates shipping method -->
91+
<actionGroup ref="AdminSwitchWebsiteActionGroup" stepKey="switchDefaultWebsite2">
92+
<argument name="website" value="_defaultWebsite"/>
93+
</actionGroup>
94+
<actionGroup ref="AdminChangeTableRatesShippingMethodStatusActionGroup" stepKey="disableTableRatesShippingMethodForDefaultWebsite">
95+
<argument name="status" value="0"/>
96+
</actionGroup>
97+
<checkOption selector="{{AdminShippingMethodTableRatesSection.carriersTableRateConditionName}}" stepKey="disableUseDefaultCondition"/>
98+
<actionGroup ref="AdminSaveConfigActionGroup" stepKey="saveConfig2"/>
99+
100+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout2"/>
101+
</after>
102+
103+
<!-- Add product to cart and check shipping prices -->
104+
<actionGroup ref="OpenStoreFrontProductPageActionGroup" stepKey="navigateToProductPage">
105+
<argument name="productUrlKey" value="$createProduct.custom_attributes[url_key]$"/>
106+
</actionGroup>
107+
108+
<actionGroup ref="StorefrontAddProductToCartActionGroup" stepKey="addProductToCart">
109+
<argument name="product" value="$createProduct$" />
110+
<argument name="productCount" value="1" />
111+
</actionGroup>
112+
113+
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckoutFromMinicart"/>
114+
115+
<actionGroup ref="GuestCheckoutFillNewShippingAddressActionGroup" stepKey="guestCheckoutFillingShippingSection">
116+
<argument name="customer" value="CustomerEntityOne" />
117+
<argument name="address" value="CustomerAddressSimple" />
118+
</actionGroup>
119+
<see selector="{{CheckoutShippingMethodsSection.shippingRatePriceByName('Fixed')}}" userInput="$5.00" stepKey="assertFlatRatedMethodPrice"/>
120+
<see selector="{{CheckoutShippingMethodsSection.shippingRatePriceByName('Table Rate')}}" userInput="$0.00" stepKey="assertTableRatedMethodPrice"/>
121+
<dontSee selector="{{CheckoutShippingMethodsSection.shippingRatePriceByName('Free Shipping')}}" userInput="$0.00" stepKey="assertFreeShippingMethodNotAvailable"/>
122+
<waitForElementClickable selector="{{CheckoutShippingMethodsSection.shippingMethodFlatRate}}" stepKey="waitForFlatRateShippingMethod"/>
123+
124+
<!-- Apply cart price rule for free shipping -->
125+
<click selector="{{CheckoutShippingMethodsSection.checkShippingMethodByName('Flat Rate')}}" stepKey="selectFlatRateShippingMethod"/>
126+
<actionGroup ref="StorefrontCheckoutClickNextButtonActionGroup" stepKey="goToPaymentStep"/>
127+
<actionGroup ref="StorefrontApplyDiscountCodeActionGroup" stepKey="applyCoupon">
128+
<argument name="discountCode" value="{{_defaultCoupon.code}}"/>
129+
</actionGroup>
130+
131+
<!-- Check shipping prices after applying cart price rule -->
132+
<actionGroup ref="StorefrontOpenHomePageActionGroup" stepKey="amOnHomePageAfterCartRuleApplied"/>
133+
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckoutFromMinicart2"/>
134+
<see selector="{{CheckoutShippingMethodsSection.shippingRatePriceByName('Fixed')}}" userInput="$5.00" stepKey="assertFlatRatedMethodPriceAfterCartRule"/>
135+
<see selector="{{CheckoutShippingMethodsSection.shippingRatePriceByName('Table Rate')}}" userInput="$15.95" stepKey="assertTableRatedMethodPriceAfterCartRule"/>
136+
<see selector="{{CheckoutShippingMethodsSection.shippingRatePriceByName('Free Shipping')}}" userInput="$0.00" stepKey="assertFreeShippingMethodAvailable"/>
137+
</test>
138+
</tests>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Country,Region/State,Zip/Postal Code,Order Subtotal (and above),Shipping Price
2+
USA,*,*,0,15.9500
3+
USA,*,*,100.0000,0.0000
4+
USA,AK,*,0.0000,0.0000
5+
USA,HI,*,0.0000,0.0000

dev/tests/integration/testsuite/Magento/Quote/Model/ShippingMethodManagementTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,12 @@ public function testTableRateWithCartRuleForFreeShipping()
168168
$rate = reset($result);
169169
$expectedResult = [
170170
'method_code' => 'bestway',
171-
'amount' => 10
171+
'amount' => 5
172172
];
173173
$this->assertEquals($expectedResult['method_code'], $rate->getMethodCode());
174174
$this->assertEquals($expectedResult['amount'], $rate->getAmount());
175175
}
176-
176+
177177
/**
178178
* @magentoDataFixture Magento/SalesRule/_files/cart_rule_100_percent_off.php
179179
* @magentoDataFixture Magento/Sales/_files/quote_with_customer.php

0 commit comments

Comments
 (0)