How To

Steps to Remove Apply Discount Code From Checkout Payment Page in Magento 2

Hello Magento Friends ?,

Today I will illustrate How to Remove Apply Discount Code From Checkout Payment Page in Magento 2. Let’s check out our previous blog, Magento 2: How to Add Custom Sidebar On Checkout Page. So, let’s start on ?

Beginning:

Discounts and offers are provided to the products and services in order to attract customers towards the store. The customers are likely to purchase more when they find any discounts. Besides, visitors can be easily converted into customers with the help of it.

But discounts are applied to the products or services for a specific period of time. After that, the store owner needs to remove or disable the discount code from the product payment page. Also, when the discount is applied only for a particular group of customers, the product payment page of other customer groups must not show the discount code.

Hence, let us find out the way to fulfill the above necessity.

Methods to Remove Apply Discount Code From Checkout Payment Page in Magento 2:

Remove Apply Discount Code From Checkout Payment Page in Magento 2 involves two methods to implement it.

Method 1: Using the CSS file

Enter the below code in your custom CSS file.

.checkout-index-index .payment-option._collapsible.opc-payment-additional.discount-code
{
    display: none;
}

Method 2: Using the XML file

Move to the following path

app/design/frontend/VENDOR/THEME/Magento_Checkout/layout/checkout_index_index.xml

And enter the below code

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
    <referenceBlock name="checkout.root">
        <arguments>
            <argument name="jsLayout" xsi:type="array">
                <item name="components" xsi:type="array">
                    <item name="checkout" xsi:type="array">
                        <item name="children" xsi:type="array">
                            <item name="steps" xsi:type="array">
                                <item name="children" xsi:type="array">
                                    <item name="billing-step" xsi:type="array">
                                        <item name="children" xsi:type="array">
                                            <item name="payment" xsi:type="array">
                                                <item name="children" xsi:type="array">
                                                    <item name="afterMethods" xsi:type="array">
                                                        <item name="children" xsi:type="array">        
                                                            <item name="discount" xsi:type="array">
                                                                <item name="config" xsi:type="array">
                                                                    <item name="componentDisabled" xsi:type="boolean">true</item>
                                                                </item>
                                                            </item>
                                                        </item>
                                                    </item>
                                                </item>
                                            </item>
                                        </item>
                                    </item>
                                </item>
                            </item>
                        </item>
                    </item>
                </item>
            </argument>
        </arguments>
    </referenceBlock>
</body>

Now run the below commands to view the effect

php bin/magento cache:clean
php bin/magento cache:flush

Ending:

Therefore, now everyone is able to Remove Apply Discount Code From Checkout Payment Page in Magento 2. While implementing the code, if you come across any difficulty notify me in the comment section below. Share the article with your Magento Developer buddies. Stay in the know for more such solutions.

Happy Coding ?

Click to rate this post!
[Total: 9 Average: 5]
Dhiren Vasoya

Dhiren Vasoya is a Director and Co-founder at MageComp, Passionate 🎖️ Certified Magento Developer👨‍💻. He has more than 9 years of experience in Magento Development and completed 850+ projects to solve the most important E-commerce challenges. He is fond❤️ of coding and if he is not busy developing then you can find him at the cricket ground, hitting boundaries.🏏

View Comments

Recent Posts

How to Delete Product Variant in a Shopify Remix App using GraphQL Mutations?

Managing a Shopify store efficiently involves keeping your product catalog organized. This includes removing outdated…

16 hours ago

6 Innovative Tools Revolutionizing E-Commerce Operations

E-commerce has transformed the way consumers shop for products and services and interact with businesses.…

3 days ago

How Upcoming Cookie Changes Will Affect Your E-commerce Website?

The e-commerce world is constantly in flux. New tech and strategies emerge daily to help…

3 days ago

Magento 2: How to Add Header and Footer in Checkout

Hello Magento Friends, In today’s blog, we will discuss adding a header and footer to…

4 days ago

Understanding Flexbox Layout in React Native

Hello React Native Friends, Building a visually appealing and responsive mobile app is crucial in…

6 days ago

HYVÄ Themes Releases: 1.3.6 & 1.3.7 – What’s New

We have brought exciting news for Magento store owners. Hyvä Themes recently released 1.3.6 and…

6 days ago