Skip to content

Commit aff512b

Browse files
authored
Merge pull request #6882 from magento-tsg/2.4-develop-pr148
[Arrows] Fixes for 2.4 (pr148) (2.4-develop)
2 parents 5dcb5a5 + 8fa8b58 commit aff512b

File tree

10 files changed

+182
-3
lines changed

10 files changed

+182
-3
lines changed

app/code/Magento/Checkout/Test/Mftf/Section/CheckoutShippingMethodsSection.xml

+1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@
2121
<element name="freeShippingShippingMethod" type="input" selector="#s_method_freeshipping_freeshipping" timeout="30"/>
2222
<element name="noQuotesMsg" type="text" selector="#checkout-step-shipping_method div"/>
2323
<element name="price" type="text" selector="//*[@id='checkout-shipping-method-load']//td[@class='col col-price']"/>
24+
<element name="shippingRatePriceByName" type="text" selector="//div[@id='checkout-shipping-method-load']//td[contains(., '{{var1}}')]/..//td//span[contains(@class, 'price')]" parameterized="true"/>
2425
</section>
2526
</sections>

app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js

+4
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,8 @@ function (
283283
label = _.map(attribute.value, function (value) {
284284
return this.getCustomAttributeOptionLabel(attribute['attribute_code'], value) || value;
285285
}, this).join(', ');
286+
} else if (typeof attribute.value === 'object') {
287+
label = _.map(Object.values(attribute.value)).join(', ');
286288
} else {
287289
label = this.getCustomAttributeOptionLabel(attribute['attribute_code'], attribute.value);
288290
}
@@ -310,6 +312,8 @@ function (
310312
if (option) {
311313
label = option.label;
312314
}
315+
} else if (value.file !== null) {
316+
label = value.file;
313317
}
314318

315319
return label;

app/code/Magento/Checkout/view/frontend/web/js/view/shipping-address/address-renderer/default.js

+4
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ define([
6969
label = _.map(attribute.value, function (value) {
7070
return this.getCustomAttributeOptionLabel(attribute['attribute_code'], value) || value;
7171
}, this).join(', ');
72+
} else if (typeof attribute.value === 'object') {
73+
label = _.map(Object.values(attribute.value)).join(', ');
7274
} else {
7375
label = this.getCustomAttributeOptionLabel(attribute['attribute_code'], attribute.value);
7476
}
@@ -96,6 +98,8 @@ define([
9698
if (option) {
9799
label = option.label;
98100
}
101+
} else if (value.file !== null) {
102+
label = value.file;
99103
}
100104

101105
return label;

app/code/Magento/Checkout/view/frontend/web/js/view/shipping-information/address-renderer/default.js

+4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ define([
4646
label = _.map(attribute.value, function (value) {
4747
return this.getCustomAttributeOptionLabel(attribute['attribute_code'], value) || value;
4848
}, this).join(', ');
49+
} else if (typeof attribute.value === 'object') {
50+
label = _.map(Object.values(attribute.value)).join(', ');
4951
} else {
5052
label = this.getCustomAttributeOptionLabel(attribute['attribute_code'], attribute.value);
5153
}
@@ -73,6 +75,8 @@ define([
7375
if (option) {
7476
label = option.label;
7577
}
78+
} else if (value.file !== null) {
79+
label = value.file;
7680
}
7781

7882
return label;

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,14 @@ private function getFreeBoxesCount(RateRequest $request)
113113
continue;
114114
}
115115

116+
$freeShippingMethod = $item->getFreeShippingMethod();
117+
116118
if ($item->getHasChildren() && $item->isShipSeparately()) {
117119
$freeBoxes += $this->getFreeBoxesCountFromChildren($item);
118-
} elseif ($item->getFreeShipping()) {
120+
} elseif (
121+
$item->getFreeShipping()
122+
&& ($freeShippingMethod === null || $freeShippingMethod === 'flatrate_flatrate')
123+
) {
119124
$freeBoxes += $item->getQty();
120125
}
121126
}

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

+15-2
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ public function collectRates(RateRequest $request)
118118
// Free shipping by qty
119119
$freeQty = 0;
120120
$freePackageValue = 0;
121+
$freeWeight = 0;
121122

122123
if ($request->getAllItems()) {
123124
foreach ($request->getAllItems() as $item) {
@@ -132,19 +133,31 @@ public function collectRates(RateRequest $request)
132133
$freeQty += $item->getQty() * ($child->getQty() - $freeShipping);
133134
}
134135
}
135-
} elseif ($item->getFreeShipping() || $item->getAddress()->getFreeShipping()) {
136+
} elseif (
137+
($item->getFreeShipping() || $item->getAddress()->getFreeShipping()) &&
138+
($item->getFreeShippingMethod() == null || $item->getFreeShippingMethod() &&
139+
$item->getFreeShippingMethod() == 'tablerate_bestway')
140+
) {
136141
$freeShipping = $item->getFreeShipping() ?
137142
$item->getFreeShipping() : $item->getAddress()->getFreeShipping();
138143
$freeShipping = is_numeric($freeShipping) ? $freeShipping : 0;
139144
$freeQty += $item->getQty() - $freeShipping;
140145
$freePackageValue += $item->getBaseRowTotal();
141146
}
147+
148+
if ($item->getFreeShippingMethod() && $item->getFreeShippingMethod() !== 'tablerate_bestway') {
149+
$freeWeight += (int) $item->getWeight();
150+
}
142151
}
143-
152+
144153
$request->setPackageValue($request->getPackageValue() - $freePackageValue);
145154
$request->setPackageValueWithDiscount($request->getPackageValueWithDiscount() - $freePackageValue);
146155
}
147156

157+
if ($freeWeight > 0) {
158+
$request->setFreeMethodWeight($freeWeight);
159+
}
160+
148161
if (!$request->getConditionName()) {
149162
$conditionName = $this->getConfigData('condition_name');
150163
$request->setConditionName($conditionName ? $conditionName : $this->_defaultConditionName);

app/code/Magento/OfflineShipping/Model/SalesRule/Calculator.php

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function processFreeShipping(\Magento\Quote\Model\Quote\Item\AbstractItem
4545
switch ($rule->getSimpleFreeShipping()) {
4646
case Rule::FREE_SHIPPING_ITEM:
4747
$item->setFreeShipping($rule->getDiscountQty() ? $rule->getDiscountQty() : true);
48+
$item->setFreeShippingMethod($item->getAddress()->getShippingMethod());
4849
break;
4950

5051
case Rule::FREE_SHIPPING_ADDRESS:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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="AdminCartPriceRuleFillCouponInfoActionGroup">
12+
<annotations>
13+
<description>Fill Cart Price Rule coupon info : Type, Code, Number of uses per coupon/customer.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="couponType" type="string" defaultValue="Specific Coupon"/>
17+
<argument name="couponCode" type="string" defaultValue="{{_defaultCoupon.code}}"/>
18+
<argument name="userPerCoupon" type="string" defaultValue="500"/>
19+
<argument name="userPerCustomer" type="string" defaultValue="1"/>
20+
</arguments>
21+
22+
<selectOption selector="{{AdminCartPriceRulesFormSection.coupon}}" userInput="{{couponType}}" stepKey="selectCouponType"/>
23+
<fillField selector="{{AdminCartPriceRulesFormSection.couponCode}}" userInput="{{couponCode}}" stepKey="fillCouponCode"/>
24+
<fillField selector="{{AdminCartPriceRulesFormSection.userPerCoupon}}" userInput="{{userPerCoupon}}" stepKey="setUserPerCoupon"/>
25+
<fillField selector="{{AdminCartPriceRulesFormSection.userPerCustomer}}" userInput="{{userPerCustomer}}" stepKey="setUserPerCustomer"/>
26+
</actionGroup>
27+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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="AdminCartPriceRuleFillShippingConditionActionGroup">
12+
<annotations>
13+
<description>Sets the provided Cart Attribute Shipping method condition type on the Admin Cart Price Rule creation/edit page.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="shippingMethodName" type="string" defaultValue="[flatrate] Fixed"/>
17+
</arguments>
18+
<click selector="{{AdminCartPriceRulesFormSection.conditionsHeader}}" stepKey="openConditionsSection" />
19+
<click selector="{{AdminCartPriceRulesFormSection.addCondition('1')}}" stepKey="addCondition"/>
20+
<selectOption selector="{{AdminCartPriceRulesFormSection.conditionSelectDropdown('1')}}" userInput="Shipping Method" stepKey="specifyCondition"/>
21+
<waitForPageLoad stepKey="waitForConditionLoad"/>
22+
<click selector="{{AdminCartPriceRulesFormSection.targetEllipsis}}" stepKey="clickEllipsis"/>
23+
<selectOption selector="{{AdminCartPriceRulesFormSection.ruleFieldByIndex('1--1')}}" userInput="{{shippingMethodName}}" stepKey="selectShippingMethod"/>
24+
</actionGroup>
25+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
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="StorefrontAssertShippingPricesPresentAfterApplyingCartRuleTest">
12+
<annotations>
13+
<features value="Shipping"/>
14+
<stories value="Cart price rules"/>
15+
<title value="Assert that shipping methods prices will be correct after cart price rule applied"/>
16+
<description value="Shipping method prices should be displayed correctly on checkout after applied cart price rule"/>
17+
<severity value="MAJOR"/>
18+
<testCaseId value="MC-42229"/>
19+
<useCaseId value="MC-24379"/>
20+
<group value="shipping"/>
21+
<group value="SalesRule"/>
22+
</annotations>
23+
<before>
24+
<createData entity="SimpleProduct2" stepKey="createProduct"/>
25+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
26+
<actionGroup ref="AdminOpenShippingMethodsConfigPageActionGroup" stepKey="openShippingMethodConfigPage"/>
27+
<actionGroup ref="AdminSwitchWebsiteActionGroup" stepKey="switchDefaultWebsite">
28+
<argument name="website" value="_defaultWebsite"/>
29+
</actionGroup>
30+
<actionGroup ref="AdminChangeTableRatesShippingMethodStatusActionGroup" stepKey="enableTableRatesShippingMethodForDefaultWebsite">
31+
<argument name="status" value="1"/>
32+
</actionGroup>
33+
<actionGroup ref="AdminImportFileTableRatesShippingMethodActionGroup" stepKey="importCSVFile">
34+
<argument name="file" value="usa_tablerates.csv"/>
35+
</actionGroup>
36+
<actionGroup ref="AdminSaveConfigActionGroup" stepKey="saveConfig"/>
37+
<actionGroup ref="AdminCartPriceRuleDeleteAllActionGroup" stepKey="deleteAllExistingCartPriceRules"/>
38+
<actionGroup ref="AdminOpenNewCartPriceRuleFormPageActionGroup" stepKey="createCartPriceRule"/>
39+
<actionGroup ref="AdminCartPriceRuleFillMainInfoActionGroup" stepKey="fillCartPriceRuleMainInfo">
40+
<argument name="name" value="{{CartPriceRuleConditionForSubtotalForMultiShipping.name}}"/>
41+
<argument name="description" value="{{CartPriceRuleConditionForSubtotalForMultiShipping.description}}"/>
42+
</actionGroup>
43+
<actionGroup ref="AdminCartPriceRuleFillCouponInfoActionGroup" stepKey="fillCartPriceRuleCouponInfo"/>
44+
<actionGroup ref="AdminCartPriceRuleFillShippingConditionActionGroup" stepKey="setCartAttributeConditionForCartPriceRule"/>
45+
<actionGroup ref="AdminCreateCartPriceRuleActionsSectionDiscountFieldsActionGroup" stepKey="fillCartPriceRuleActionsSection">
46+
<argument name="rule" value="CartPriceRuleConditionForSubtotalForMultiShipping"/>
47+
</actionGroup>
48+
<actionGroup ref="AdminCreateCartPriceRuleActionsSectionFreeShippingActionGroup" stepKey="fillCartPriceRuleFreeShippingActionsSection">
49+
<argument name="freeShippingOption" value="{{CartPriceRuleConditionForSubtotalForMultiShipping.simple_free_shipping}}"/>
50+
</actionGroup>
51+
<actionGroup ref="AdminCartPriceRuleSaveActionGroup" stepKey="saveCartPriceRule"/>
52+
</before>
53+
<after>
54+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
55+
<actionGroup ref="AdminCartPriceRuleDeleteAllActionGroup" stepKey="deleteAllCartPriceRules"/>
56+
<actionGroup ref="AdminOpenShippingMethodsConfigPageActionGroup" stepKey="openShippingMethodConfigPage2"/>
57+
<actionGroup ref="AdminSwitchWebsiteActionGroup" stepKey="switchDefaultWebsite2">
58+
<argument name="website" value="_defaultWebsite"/>
59+
</actionGroup>
60+
<actionGroup ref="AdminChangeTableRatesShippingMethodStatusActionGroup" stepKey="disableTableRatesShippingMethodForDefaultWebsite">
61+
<argument name="status" value="0"/>
62+
</actionGroup>
63+
<actionGroup ref="AdminSaveConfigActionGroup" stepKey="saveConfig2"/>
64+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
65+
</after>
66+
67+
<actionGroup ref="OpenStoreFrontProductPageActionGroup" stepKey="navigateToProductPage">
68+
<argument name="productUrlKey" value="$createProduct.custom_attributes[url_key]$"/>
69+
</actionGroup>
70+
71+
<actionGroup ref="StorefrontAddProductToCartActionGroup" stepKey="addProductToCart">
72+
<argument name="product" value="$createProduct$" />
73+
<argument name="productCount" value="1" />
74+
</actionGroup>
75+
76+
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckoutFromMinicart"/>
77+
78+
<actionGroup ref="GuestCheckoutFillNewShippingAddressActionGroup" stepKey="guestCheckoutFillingShippingSection">
79+
<argument name="customer" value="CustomerEntityOne" />
80+
<argument name="address" value="CustomerAddressSimple" />
81+
</actionGroup>
82+
<see selector="{{CheckoutShippingMethodsSection.shippingRatePriceByName('Fixed')}}" userInput="$5.00" stepKey="assertFlatRatedMethodPrice"/>
83+
<see selector="{{CheckoutShippingMethodsSection.shippingRatePriceByName('Table Rate')}}" userInput="$7.99" stepKey="assertTableRatedMethodPrice"/>
84+
<click selector="{{CheckoutShippingMethodsSection.checkShippingMethodByName('Flat Rate')}}" stepKey="selectFlatRateShippingMethod"/>
85+
<actionGroup ref="StorefrontCheckoutClickNextButtonActionGroup" stepKey="goToPaymentStep"/>
86+
<actionGroup ref="StorefrontApplyDiscountCodeActionGroup" stepKey="applyCoupon">
87+
<argument name="discountCode" value="{{_defaultCoupon.code}}"/>
88+
</actionGroup>
89+
90+
<actionGroup ref="StorefrontOpenHomePageActionGroup" stepKey="amOnHomePageAfterCartRuleApplied"/>
91+
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckoutFromMinicart2"/>
92+
<see selector="{{CheckoutShippingMethodsSection.shippingRatePriceByName('Fixed')}}" userInput="$0.00" stepKey="assertFlatRatedMethodPriceAfterCartRule"/>
93+
<see selector="{{CheckoutShippingMethodsSection.shippingRatePriceByName('Table Rate')}}" userInput="$7.99" stepKey="assertTableRatedMethodPriceAfterCartRule"/>
94+
</test>
95+
</tests>

0 commit comments

Comments
 (0)