Skip to content

Commit 3cb986c

Browse files
committed
MC-42543: [Magento Cloud] 100% off cart discount rule not working the second checkout currently when checking out with virtual item
- Add MFTF test with the solution
1 parent d1ba944 commit 3cb986c

File tree

4 files changed

+75
-0
lines changed

4 files changed

+75
-0
lines changed

app/code/Magento/Quote/Model/Cart/CartTotalRepository.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public function get($cartId): QuoteTotalsInterface
9090
/** @var \Magento\Quote\Model\Quote $quote */
9191
$quote = $this->quoteRepository->getActive($cartId);
9292
if ($quote->isVirtual()) {
93+
$quote->collectTotals();
9394
$addressTotalsData = $quote->getBillingAddress()->getData();
9495
$addressTotals = $quote->getBillingAddress()->getTotals();
9596
} else {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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="AdminCreateCartPriceRuleWithCustomerSegmentActionGroup">
12+
<annotations>
13+
<description>
14+
Clicks on the 'Actions' section on the Admin Cart Price Rule creation with customer segment action.
15+
</description>
16+
</annotations>
17+
<arguments>
18+
<argument name="rule" type="entity"/>
19+
</arguments>
20+
21+
<fillField selector="{{AdminCartPriceRulesFormSection.ruleName}}" userInput="{{rule.name}}" stepKey="fillRuleName"/>
22+
<fillField selector="{{AdminCartPriceRulesFormSection.description}}" userInput="{{rule.description}}" stepKey="fillDescription"/>
23+
<selectOption selector="{{AdminCartPriceRulesFormSection.websites}}" userInput="{{rule.websites}}" stepKey="selectWebsites"/>
24+
<selectOption selector="{{AdminCartPriceRulesFormSection.customerGroups}}" parameterArray="[{{rule.customerGroups}}]" stepKey="selectCustomerGroup"/>
25+
<selectOption selector="{{AdminCartPriceRulesFormSection.coupon}}" userInput="{{rule.coupon_type}}" stepKey="selectCouponType"/>
26+
27+
<!-- Expand the conditions section and add required condition-->
28+
<scrollTo selector="{{AdminCartPriceRulesFormSection.conditionsHeader}}" stepKey="scrollToConditionsHeader"/>
29+
<conditionalClick selector="{{AdminCartPriceRulesFormSection.conditionsHeader}}" dependentSelector="{{AdminCartPriceRulesFormSection.conditionsHeader}}" visible="true" stepKey="clickToExpandConditions"/>
30+
<click selector="{{AdminCartPriceRulesFormSection.newCondition}}" stepKey="clickNewCondition"/>
31+
<waitForElementVisible selector="{{AdminCartPriceRulesFormSection.conditionSelect}}" time="240" stepKey="waitForSelectOptionVisible"/>
32+
<selectOption selector="{{AdminCartPriceRulesFormSection.conditionSelect}}" userInput="Customer Segment" stepKey="selectCondition1"/>
33+
<waitForPageLoad stepKey="waitForConditionLoad"/>
34+
<click selector="{{AdminCartPriceRulesFormSection.targetEllipsis}}" stepKey="clickEllipsis"/>
35+
<waitForPageLoad time="20" stepKey="waitForOperator"/>
36+
<click selector="{{AdminCartPriceRulesFormSection.openList}}" stepKey="openList"/>
37+
<waitForPageLoad time="60" stepKey="waitForGrid"/>
38+
39+
<checkOption selector="{{AdminCartPriceRulesFormSection.selectAll}}" stepKey="checkAll"/>
40+
<waitForPageLoad stepKey="waitForChecking"/>
41+
<moveMouseOver selector="{{AdminCartPriceRulesFormSection.setSegment}}" stepKey="moveOnButton"/>
42+
<click selector="{{AdminCartPriceRulesFormSection.setSegment}}" stepKey="setCustomerSegment"/>
43+
<waitForPageLoad time="60" stepKey="waitForSelectCustomerSegment"/>
44+
<click selector="{{AdminMainActionsSection.saveAndContinue}}" stepKey="clickSaveButton"/>
45+
<see selector="{{AdminCartPriceRulesSection.messages}}" userInput="You saved the rule." stepKey="seeSuccessMessage"/>
46+
</actionGroup>
47+
</actionGroups>

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,4 +483,29 @@
483483
<data key="discount_step">1</data>
484484
<data key="stop_rules_processing">true</data>
485485
</entity>
486+
487+
<entity name="FreeProductGroupCartPriceRule" type="SalesRule">
488+
<data key="name" unique="suffix">FreeProductGroupCartPriceRule-</data>
489+
<data key="description">100% off free product group</data>
490+
<data key="websites">Main Website</data>
491+
<data key="customerGroups">'NOT LOGGED IN', 'General', 'Wholesale', 'Retailer'</data>
492+
<data key="coupon_type">No Coupon</data>
493+
<data key="subtotal">560</data>
494+
<data key="uses_per_customer">0</data>
495+
<data key="is_active">true</data>
496+
<data key="is_advanced">true</data>
497+
<data key="sort_order">0</data>
498+
<data key="simple_action">by_percent</data>
499+
<data key="discount_amount">100</data>
500+
<data key="discount_qty">0</data>
501+
<data key="maximumQtyDiscount">0</data>
502+
<data key="discount_step">0</data>
503+
<data key="apply_to_shipping">true</data>
504+
<data key="is_rss">true</data>
505+
<data key="use_auto_generation">false</data>
506+
<data key="uses_per_coupon">0</data>
507+
<data key="simple_free_shipping">0</data>
508+
<data key="defaultRuleLabelAllStoreViews">Free Shipping in Rule conditions</data>
509+
<data key="defaultStoreView">Free Shipping in Rule conditions</data>
510+
</entity>
486511
</entities>

app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
<element name="websitesOptions" type="select" selector="[name='website_ids'] option"/>
2525
<element name="customerGroups" type="multiselect" selector="select[name='customer_group_ids']"/>
2626
<element name="customerGroupsOptions" type="multiselect" selector="select[name='customer_group_ids'] option"/>
27+
<element name="selectAllCustomerGroup" type="button" selector="button[data-action='select-all']"/>
28+
<element name="pressCustomerGroupDoneBtn" type="button" selector="button.action-secondary"/>
2729
<element name="coupon" type="select" selector="select[name='coupon_type']"/>
2830
<element name="couponCode" type="input" selector="input[name='coupon_code']"/>
2931
<element name="useAutoGeneration" type="checkbox" selector="input[name='use_auto_generation']"/>

0 commit comments

Comments
 (0)