Skip to content

Commit 32c4c3e

Browse files
ENGCOM-8426: #30255: Fixed "The coupon code has been accepted." message remains after a Coupon Code was removed #30391
2 parents 3f02c8a + 2ccc605 commit 32c4c3e

File tree

5 files changed

+91
-0
lines changed

5 files changed

+91
-0
lines changed

app/code/Magento/Sales/Controller/Adminhtml/Order/Create.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,8 @@ protected function _processActionData($action = null)
344344
$this->messageManager->addSuccessMessage(__('The coupon code has been accepted.'));
345345
}
346346
}
347+
} elseif (isset($data['coupon']['code']) && empty($couponCode)) {
348+
$this->messageManager->addSuccessMessage(__('The coupon code has been removed.'));
347349
}
348350

349351
return $this;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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="AdminRemoveCouponFromOrderActionGroup">
12+
<click selector="{{AdminOrderFormItemsSection.removeCoupon}}" stepKey="removeCoupon"/>
13+
<waitForPageLoad stepKey="waitForRemovingCoupon"/>
14+
<dontSee selector="{{AdminOrderDetailsMessagesSection.successMessage}}" userInput="The coupon code has been accepted." stepKey="dontSeePreviousMessage"/>
15+
<see selector="{{AdminOrderDetailsMessagesSection.successMessage}}" userInput="The coupon code has been removed." stepKey="seeSuccessMessage"/>
16+
</actionGroup>
17+
</actionGroups>

app/code/Magento/Sales/Test/Mftf/Section/AdminOrderFormItemsSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@
3535
<element name="configure" type="button" selector=".product-configure-block button.action-default.scalable" timeout="30"/>
3636
<element name="couponCode" type="input" selector="#order-coupons input" timeout="30"/>
3737
<element name="applyCoupon" type="button" selector="#order-coupons button"/>
38+
<element name="removeCoupon" type="button" selector=".added-coupon-code .action-remove"/>
3839
</section>
3940
</sections>
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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="AdminCreateOrderToVerifyApplyAndRemoveCouponCodeTest">
12+
<annotations>
13+
<stories value="Create Order with offline payment methods"/>
14+
<title value="Create Order to verify apply and remove coupon code test"/>
15+
<description value="Create Order to verify apply and remove coupon code test"/>
16+
<severity value="AVERAGE"/>
17+
<testCaseId value="MC-38919"/>
18+
<group value="sales"/>
19+
</annotations>
20+
<before>
21+
<actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin"/>
22+
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
23+
<createData entity="SimpleProduct2" stepKey="createSimpleProduct">
24+
<field key="price">10</field>
25+
</createData>
26+
<createData entity="SalesRuleSpecificCouponWithFixedDiscount" stepKey="createCartPriceRule"/>
27+
<createData entity="SimpleSalesRuleCoupon" stepKey="createCouponForCartPriceRule">
28+
<requiredEntity createDataKey="createCartPriceRule"/>
29+
</createData>
30+
<magentoCLI
31+
command="config:set {{EnablePaymentBankTransferConfigData.path}} {{EnablePaymentBankTransferConfigData.value}}"
32+
stepKey="enableBankTransferPayment"/>
33+
<magentoCLI command="config:set {{EnableFlatRateConfigData.path}} {{EnableFlatRateConfigData.value}}"
34+
stepKey="enableFlatRate"/>
35+
</before>
36+
<after>
37+
<magentoCLI
38+
command="config:set {{DisablePaymentBankTransferConfigData.path}} {{DisablePaymentBankTransferConfigData.value}}"
39+
stepKey="disableBankTransferPayment"/>
40+
<deleteData createDataKey="createCartPriceRule" stepKey="deleteCartPriceRule"/>
41+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
42+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
43+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
44+
</after>
45+
<actionGroup ref="NavigateToNewOrderPageExistingCustomerActionGroup" stepKey="goToCreateOrderPage">
46+
<argument name="customer" value="$$createCustomer$$"/>
47+
</actionGroup>
48+
<actionGroup ref="AddSimpleProductToOrderActionGroup" stepKey="addProductToOrder">
49+
<argument name="product" value="$$createSimpleProduct$$"/>
50+
</actionGroup>
51+
<actionGroup ref="AdminApplyCouponToOrderActionGroup" stepKey="applyCoupon">
52+
<argument name="couponCode" value="$$createCouponForCartPriceRule.code$$"/>
53+
</actionGroup>
54+
<actionGroup ref="AdminRemoveCouponFromOrderActionGroup" stepKey="removeCoupon"/>
55+
<actionGroup ref="AdminSelectFlatRateShippingMethodActionGroup" stepKey="selectFlatRateShippingMethod"/>
56+
<waitForElementVisible selector="{{AdminOrderFormPaymentSection.paymentBlock}}"
57+
stepKey="waitForPaymentOptions"/>
58+
<conditionalClick selector="{{AdminOrderFormPaymentSection.bankTransferOption}}"
59+
dependentSelector="{{AdminOrderFormPaymentSection.bankTransferOption}}" visible="true"
60+
stepKey="checkBankTransferOption"/>
61+
<actionGroup ref="AdminSubmitOrderActionGroup" stepKey="submitOrder"/>
62+
<grabTextFrom selector="|Order # (\d+)|" stepKey="getOrderId"/>
63+
<amOnPage url="{{AdminOrdersPage.url}}" stepKey="goToOrdersPage"/>
64+
<waitForPageLoad stepKey="waitForOrdersPageLoad"/>
65+
<actionGroup ref="FilterOrderGridByIdActionGroup" stepKey="filterOrdersGridById">
66+
<argument name="orderId" value="$getOrderId"/>
67+
</actionGroup>
68+
<click selector="{{AdminDataGridTableSection.firstRow}}" stepKey="clickCreatedOrderInGrid"/>
69+
</test>
70+
</tests>

app/code/Magento/Sales/i18n/en_US.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,3 +803,4 @@ If set YES Email field will be required during Admin order creation for new Cust
803803
"Could not save the shipment tracking","Could not save the shipment tracking"
804804
"Please enter a coupon code!","Please enter a coupon code!"
805805
"Reorder is not available.","Reorder is not available."
806+
"The coupon code has been removed.","The coupon code has been removed."

0 commit comments

Comments
 (0)