Skip to content

Commit

Permalink
Merge branch '2.4-develop' of github.com:magento-commerce/magento2ce …
Browse files Browse the repository at this point in the history
…into jquery-upgrade
  • Loading branch information
eliseacornejo committed May 27, 2021
2 parents 979c0f7 + aff512b commit 544bbaa
Show file tree
Hide file tree
Showing 10 changed files with 182 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
<element name="freeShippingShippingMethod" type="input" selector="#s_method_freeshipping_freeshipping" timeout="30"/>
<element name="noQuotesMsg" type="text" selector="#checkout-step-shipping_method div"/>
<element name="price" type="text" selector="//*[@id='checkout-shipping-method-load']//td[@class='col col-price']"/>
<element name="shippingRatePriceByName" type="text" selector="//div[@id='checkout-shipping-method-load']//td[contains(., '{{var1}}')]/..//td//span[contains(@class, 'price')]" parameterized="true"/>
</section>
</sections>
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ function (
label = _.map(attribute.value, function (value) {
return this.getCustomAttributeOptionLabel(attribute['attribute_code'], value) || value;
}, this).join(', ');
} else if (typeof attribute.value === 'object') {
label = _.map(Object.values(attribute.value)).join(', ');
} else {
label = this.getCustomAttributeOptionLabel(attribute['attribute_code'], attribute.value);
}
Expand Down Expand Up @@ -310,6 +312,8 @@ function (
if (option) {
label = option.label;
}
} else if (value.file !== null) {
label = value.file;
}

return label;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ define([
label = _.map(attribute.value, function (value) {
return this.getCustomAttributeOptionLabel(attribute['attribute_code'], value) || value;
}, this).join(', ');
} else if (typeof attribute.value === 'object') {
label = _.map(Object.values(attribute.value)).join(', ');
} else {
label = this.getCustomAttributeOptionLabel(attribute['attribute_code'], attribute.value);
}
Expand Down Expand Up @@ -96,6 +98,8 @@ define([
if (option) {
label = option.label;
}
} else if (value.file !== null) {
label = value.file;
}

return label;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ define([
label = _.map(attribute.value, function (value) {
return this.getCustomAttributeOptionLabel(attribute['attribute_code'], value) || value;
}, this).join(', ');
} else if (typeof attribute.value === 'object') {
label = _.map(Object.values(attribute.value)).join(', ');
} else {
label = this.getCustomAttributeOptionLabel(attribute['attribute_code'], attribute.value);
}
Expand Down Expand Up @@ -73,6 +75,8 @@ define([
if (option) {
label = option.label;
}
} else if (value.file !== null) {
label = value.file;
}

return label;
Expand Down
7 changes: 6 additions & 1 deletion app/code/Magento/OfflineShipping/Model/Carrier/Flatrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,14 @@ private function getFreeBoxesCount(RateRequest $request)
continue;
}

$freeShippingMethod = $item->getFreeShippingMethod();

if ($item->getHasChildren() && $item->isShipSeparately()) {
$freeBoxes += $this->getFreeBoxesCountFromChildren($item);
} elseif ($item->getFreeShipping()) {
} elseif (
$item->getFreeShipping()
&& ($freeShippingMethod === null || $freeShippingMethod === 'flatrate_flatrate')
) {
$freeBoxes += $item->getQty();
}
}
Expand Down
17 changes: 15 additions & 2 deletions app/code/Magento/OfflineShipping/Model/Carrier/Tablerate.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public function collectRates(RateRequest $request)
// Free shipping by qty
$freeQty = 0;
$freePackageValue = 0;
$freeWeight = 0;

if ($request->getAllItems()) {
foreach ($request->getAllItems() as $item) {
Expand All @@ -132,19 +133,31 @@ public function collectRates(RateRequest $request)
$freeQty += $item->getQty() * ($child->getQty() - $freeShipping);
}
}
} elseif ($item->getFreeShipping() || $item->getAddress()->getFreeShipping()) {
} elseif (
($item->getFreeShipping() || $item->getAddress()->getFreeShipping()) &&
($item->getFreeShippingMethod() == null || $item->getFreeShippingMethod() &&
$item->getFreeShippingMethod() == 'tablerate_bestway')
) {
$freeShipping = $item->getFreeShipping() ?
$item->getFreeShipping() : $item->getAddress()->getFreeShipping();
$freeShipping = is_numeric($freeShipping) ? $freeShipping : 0;
$freeQty += $item->getQty() - $freeShipping;
$freePackageValue += $item->getBaseRowTotal();
}

if ($item->getFreeShippingMethod() && $item->getFreeShippingMethod() !== 'tablerate_bestway') {
$freeWeight += (int) $item->getWeight();
}
}

$request->setPackageValue($request->getPackageValue() - $freePackageValue);
$request->setPackageValueWithDiscount($request->getPackageValueWithDiscount() - $freePackageValue);
}

if ($freeWeight > 0) {
$request->setFreeMethodWeight($freeWeight);
}

if (!$request->getConditionName()) {
$conditionName = $this->getConfigData('condition_name');
$request->setConditionName($conditionName ? $conditionName : $this->_defaultConditionName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function processFreeShipping(\Magento\Quote\Model\Quote\Item\AbstractItem
switch ($rule->getSimpleFreeShipping()) {
case Rule::FREE_SHIPPING_ITEM:
$item->setFreeShipping($rule->getDiscountQty() ? $rule->getDiscountQty() : true);
$item->setFreeShippingMethod($item->getAddress()->getShippingMethod());
break;

case Rule::FREE_SHIPPING_ADDRESS:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AdminCartPriceRuleFillCouponInfoActionGroup">
<annotations>
<description>Fill Cart Price Rule coupon info : Type, Code, Number of uses per coupon/customer.</description>
</annotations>
<arguments>
<argument name="couponType" type="string" defaultValue="Specific Coupon"/>
<argument name="couponCode" type="string" defaultValue="{{_defaultCoupon.code}}"/>
<argument name="userPerCoupon" type="string" defaultValue="500"/>
<argument name="userPerCustomer" type="string" defaultValue="1"/>
</arguments>

<selectOption selector="{{AdminCartPriceRulesFormSection.coupon}}" userInput="{{couponType}}" stepKey="selectCouponType"/>
<fillField selector="{{AdminCartPriceRulesFormSection.couponCode}}" userInput="{{couponCode}}" stepKey="fillCouponCode"/>
<fillField selector="{{AdminCartPriceRulesFormSection.userPerCoupon}}" userInput="{{userPerCoupon}}" stepKey="setUserPerCoupon"/>
<fillField selector="{{AdminCartPriceRulesFormSection.userPerCustomer}}" userInput="{{userPerCustomer}}" stepKey="setUserPerCustomer"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AdminCartPriceRuleFillShippingConditionActionGroup">
<annotations>
<description>Sets the provided Cart Attribute Shipping method condition type on the Admin Cart Price Rule creation/edit page.</description>
</annotations>
<arguments>
<argument name="shippingMethodName" type="string" defaultValue="[flatrate] Fixed"/>
</arguments>
<click selector="{{AdminCartPriceRulesFormSection.conditionsHeader}}" stepKey="openConditionsSection" />
<click selector="{{AdminCartPriceRulesFormSection.addCondition('1')}}" stepKey="addCondition"/>
<selectOption selector="{{AdminCartPriceRulesFormSection.conditionSelectDropdown('1')}}" userInput="Shipping Method" stepKey="specifyCondition"/>
<waitForPageLoad stepKey="waitForConditionLoad"/>
<click selector="{{AdminCartPriceRulesFormSection.targetEllipsis}}" stepKey="clickEllipsis"/>
<selectOption selector="{{AdminCartPriceRulesFormSection.ruleFieldByIndex('1--1')}}" userInput="{{shippingMethodName}}" stepKey="selectShippingMethod"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="StorefrontAssertShippingPricesPresentAfterApplyingCartRuleTest">
<annotations>
<features value="Shipping"/>
<stories value="Cart price rules"/>
<title value="Assert that shipping methods prices will be correct after cart price rule applied"/>
<description value="Shipping method prices should be displayed correctly on checkout after applied cart price rule"/>
<severity value="MAJOR"/>
<testCaseId value="MC-42229"/>
<useCaseId value="MC-24379"/>
<group value="shipping"/>
<group value="SalesRule"/>
</annotations>
<before>
<createData entity="SimpleProduct2" stepKey="createProduct"/>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
<actionGroup ref="AdminOpenShippingMethodsConfigPageActionGroup" stepKey="openShippingMethodConfigPage"/>
<actionGroup ref="AdminSwitchWebsiteActionGroup" stepKey="switchDefaultWebsite">
<argument name="website" value="_defaultWebsite"/>
</actionGroup>
<actionGroup ref="AdminChangeTableRatesShippingMethodStatusActionGroup" stepKey="enableTableRatesShippingMethodForDefaultWebsite">
<argument name="status" value="1"/>
</actionGroup>
<actionGroup ref="AdminImportFileTableRatesShippingMethodActionGroup" stepKey="importCSVFile">
<argument name="file" value="usa_tablerates.csv"/>
</actionGroup>
<actionGroup ref="AdminSaveConfigActionGroup" stepKey="saveConfig"/>
<actionGroup ref="AdminCartPriceRuleDeleteAllActionGroup" stepKey="deleteAllExistingCartPriceRules"/>
<actionGroup ref="AdminOpenNewCartPriceRuleFormPageActionGroup" stepKey="createCartPriceRule"/>
<actionGroup ref="AdminCartPriceRuleFillMainInfoActionGroup" stepKey="fillCartPriceRuleMainInfo">
<argument name="name" value="{{CartPriceRuleConditionForSubtotalForMultiShipping.name}}"/>
<argument name="description" value="{{CartPriceRuleConditionForSubtotalForMultiShipping.description}}"/>
</actionGroup>
<actionGroup ref="AdminCartPriceRuleFillCouponInfoActionGroup" stepKey="fillCartPriceRuleCouponInfo"/>
<actionGroup ref="AdminCartPriceRuleFillShippingConditionActionGroup" stepKey="setCartAttributeConditionForCartPriceRule"/>
<actionGroup ref="AdminCreateCartPriceRuleActionsSectionDiscountFieldsActionGroup" stepKey="fillCartPriceRuleActionsSection">
<argument name="rule" value="CartPriceRuleConditionForSubtotalForMultiShipping"/>
</actionGroup>
<actionGroup ref="AdminCreateCartPriceRuleActionsSectionFreeShippingActionGroup" stepKey="fillCartPriceRuleFreeShippingActionsSection">
<argument name="freeShippingOption" value="{{CartPriceRuleConditionForSubtotalForMultiShipping.simple_free_shipping}}"/>
</actionGroup>
<actionGroup ref="AdminCartPriceRuleSaveActionGroup" stepKey="saveCartPriceRule"/>
</before>
<after>
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
<actionGroup ref="AdminCartPriceRuleDeleteAllActionGroup" stepKey="deleteAllCartPriceRules"/>
<actionGroup ref="AdminOpenShippingMethodsConfigPageActionGroup" stepKey="openShippingMethodConfigPage2"/>
<actionGroup ref="AdminSwitchWebsiteActionGroup" stepKey="switchDefaultWebsite2">
<argument name="website" value="_defaultWebsite"/>
</actionGroup>
<actionGroup ref="AdminChangeTableRatesShippingMethodStatusActionGroup" stepKey="disableTableRatesShippingMethodForDefaultWebsite">
<argument name="status" value="0"/>
</actionGroup>
<actionGroup ref="AdminSaveConfigActionGroup" stepKey="saveConfig2"/>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
</after>

<actionGroup ref="OpenStoreFrontProductPageActionGroup" stepKey="navigateToProductPage">
<argument name="productUrlKey" value="$createProduct.custom_attributes[url_key]$"/>
</actionGroup>

<actionGroup ref="StorefrontAddProductToCartActionGroup" stepKey="addProductToCart">
<argument name="product" value="$createProduct$" />
<argument name="productCount" value="1" />
</actionGroup>

<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckoutFromMinicart"/>

<actionGroup ref="GuestCheckoutFillNewShippingAddressActionGroup" stepKey="guestCheckoutFillingShippingSection">
<argument name="customer" value="CustomerEntityOne" />
<argument name="address" value="CustomerAddressSimple" />
</actionGroup>
<see selector="{{CheckoutShippingMethodsSection.shippingRatePriceByName('Fixed')}}" userInput="$5.00" stepKey="assertFlatRatedMethodPrice"/>
<see selector="{{CheckoutShippingMethodsSection.shippingRatePriceByName('Table Rate')}}" userInput="$7.99" stepKey="assertTableRatedMethodPrice"/>
<click selector="{{CheckoutShippingMethodsSection.checkShippingMethodByName('Flat Rate')}}" stepKey="selectFlatRateShippingMethod"/>
<actionGroup ref="StorefrontCheckoutClickNextButtonActionGroup" stepKey="goToPaymentStep"/>
<actionGroup ref="StorefrontApplyDiscountCodeActionGroup" stepKey="applyCoupon">
<argument name="discountCode" value="{{_defaultCoupon.code}}"/>
</actionGroup>

<actionGroup ref="StorefrontOpenHomePageActionGroup" stepKey="amOnHomePageAfterCartRuleApplied"/>
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckoutFromMinicart2"/>
<see selector="{{CheckoutShippingMethodsSection.shippingRatePriceByName('Fixed')}}" userInput="$0.00" stepKey="assertFlatRatedMethodPriceAfterCartRule"/>
<see selector="{{CheckoutShippingMethodsSection.shippingRatePriceByName('Table Rate')}}" userInput="$7.99" stepKey="assertTableRatedMethodPriceAfterCartRule"/>
</test>
</tests>

0 comments on commit 544bbaa

Please sign in to comment.