Skip to content

Commit d56db5b

Browse files
committed
set correct remaining available discount amount when applying fixed price cart rules to bundle products
1 parent 26acabe commit d56db5b

File tree

3 files changed

+57
-3
lines changed

3 files changed

+57
-3
lines changed

app/code/Magento/SalesRule/Model/Rule/Action/Discount/CartFixed.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,16 @@ public function calculate($rule, $item, $qty)
111111
$address,
112112
$baseRuleTotals
113113
) : $baseRuleTotals;
114-
$availableDiscountAmount = $this->cartFixedDiscountHelper
114+
$maximumItemDiscount = $this->cartFixedDiscountHelper
115115
->getDiscountAmount(
116116
$ruleDiscount,
117117
$qty,
118118
$baseItemPrice,
119119
$baseRuleTotals,
120120
$discountType
121121
);
122-
$quoteAmount = $this->priceCurrency->convert($availableDiscountAmount, $store);
123-
$baseDiscountAmount = min($baseItemPrice * $qty, $availableDiscountAmount);
122+
$quoteAmount = $this->priceCurrency->convert($maximumItemDiscount, $store);
123+
$baseDiscountAmount = min($baseItemPrice * $qty, $maximumItemDiscount);
124124
$this->deltaPriceRound->reset($discountType);
125125
} else {
126126
$baseRuleTotals = $shippingMethod ?

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,9 @@
261261
<entity name="SalesRuleNoCouponWithFixedDiscount" extends="ApiCartRule">
262262
<data key="simple_action">by_fixed</data>
263263
</entity>
264+
<entity name="SalesRuleNoCouponWithFixedDiscountWholeCart" extends="ApiCartRule">
265+
<data key="simple_action">cart_fixed</data>
266+
</entity>
264267
<entity name="ActiveSalesRuleWithPercentPriceDiscountCoupon">
265268
<data key="name" unique="suffix">Cart Price Rule with Specific Coupon</data>
266269
<data key="description">Description for Cart Price Rule</data>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="StorefrontAssertFixedCartDiscountAmountForBundleProductTest">
11+
<annotations>
12+
<features value="SalesRule"/>
13+
<stories value="Fixed Amount Cart Price Rule"/>
14+
<title value="Checking Fixed Amount Cart Price Rule is correctly applied to bundle products"/>
15+
<description value="Checking Fixed Amount Cart Price Rule is correctly applied to bundle products"/>
16+
<severity value="AVERAGE"/>
17+
<group value="SalesRule"/>
18+
</annotations>
19+
<before>
20+
<createData entity="SalesRuleNoCouponWithFixedDiscountWholeCart" stepKey="createSalesRule"/>
21+
<actionGroup ref="AdminCreateApiDynamicBundleProductAllOptionTypesActionGroup" stepKey="createBundleProduct"/>
22+
</before>
23+
<after>
24+
<deleteData createDataKey="createSalesRule" stepKey="deleteSalesRule"/>
25+
<deleteData createDataKey="createBundleProductCreateBundleProduct" stepKey="deleteBundleProduct"/>
26+
<deleteData createDataKey="simpleProduct1CreateBundleProduct" stepKey="deleteSimpleProduct1"/>
27+
</after>
28+
<actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="openProductPage">
29+
<argument name="productUrl" value="$$createBundleProductCreateBundleProduct.custom_attributes[url_key]$$"/>
30+
</actionGroup>
31+
<click selector="{{StorefrontBundledSection.addToCart}}" stepKey="clickCustomize"/>
32+
<selectOption selector="{{StorefrontBundledSection.dropDownOptionOneProducts('Drop-down Option')}}" userInput="$$simpleProduct2CreateBundleProduct.sku$$ +$$$simpleProduct2CreateBundleProduct.price$$.00" stepKey="selectOption0Product1"/>
33+
<seeOptionIsSelected selector="{{StorefrontBundledSection.dropDownOptionOneProducts('Drop-down Option')}}" userInput="$$simpleProduct2CreateBundleProduct.sku$$ +$$$simpleProduct2CreateBundleProduct.price$$.00" stepKey="checkOption0Product1"/>
34+
<checkOption selector="{{StorefrontBundledSection.radioButtonOptionTwoProducts('Radio Buttons Option', '1')}}" stepKey="selectOption1Product0"/>
35+
<seeCheckboxIsChecked selector="{{StorefrontBundledSection.radioButtonOptionTwoProducts('Radio Buttons Option', '1')}}" stepKey="checkOption1Product0"/>
36+
<checkOption selector="{{StorefrontBundledSection.checkboxOptionThreeProducts('Checkbox Option', '1')}}" stepKey="selectOption2Product0"/>
37+
<seeCheckboxIsChecked selector="{{StorefrontBundledSection.checkboxOptionThreeProducts('Checkbox Option', '1')}}" stepKey="checkOption2Product0"/>
38+
<checkOption selector="{{StorefrontBundledSection.checkboxOptionThreeProducts('Checkbox Option', '2')}}" stepKey="selectOption2Product1"/>
39+
<seeCheckboxIsChecked selector="{{StorefrontBundledSection.checkboxOptionThreeProducts('Checkbox Option', '1')}}" stepKey="checkOption2Product1"/>
40+
<actionGroup ref="StorefrontEnterProductQuantityAndAddToTheCartActionGroup" stepKey="enterProductQuantityAndAddToTheCart">
41+
<argument name="quantity" value="1"/>
42+
</actionGroup>
43+
<actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="openShoppingCartPage"/>
44+
<actionGroup ref="StorefrontCheckCartActionGroup" stepKey="cartAssert" after="openShoppingCartPage">
45+
<argument name="subtotal" value="60.00"/>
46+
<argument name="shipping" value="5.00"/>
47+
<argument name="shippingMethod" value="Flat Rate - Fixed"/>
48+
<argument name="total" value="15.00"/>
49+
</actionGroup>
50+
</test>
51+
</tests>

0 commit comments

Comments
 (0)