Magento 2: How to Remove "Apply Discount Code" From Checkout?

Magento 2: How to Remove "Apply Discount Code" From Checkout?

Ecommerce is not as easy as it may seem. Online retailers need to take care of a lot of things, often simultaneously. From finding a winning product to listing and optimization, from sourcing and logistics to customer service, and from quality control to payment handling, every step requires due diligence.

But more than anything else, eCommerce business owners need to find ways to increase their sales. They need to make sure their business does not stagnate or go down. This includes running marketing campaigns and on-site promotions and deals.

What are Discount Codes and How are They Helpful?

Discount codes are usually a combination of numbers and letters that make customers eligible for discounts on individual items or the entire order. Customers enter the code during the checkout process to redeem a specific offer. Discount codes are used as an on-site marketing strategy on special occasions such as Christmas, easter, or holiday campaigns.

Discount codes encourage customers to buy from a website to avail themselves discounts. They benefit both customers and businesses. Customers buy the product they want for a lower price and the store generates revenue. Discount codes work well for both new and returning customers and are a great way to increase customer acquisition and meet sales goals.

Why Would you Want to Remove ‘Apply Discount Code’ From Your Magento 2 Store?

While promotional codes have the potential to increase sales, they can also damage your profits. They can also have a negative impact on your brand. So before issuing discount codes, make sure they are well thought out. Keep the following points in mind when using discount codes in your store.
  • The discount strategy should be aligned with your brand
  • Don’t complicate the discount promo
  • Don’t offer hefty discounts
  • Target the right customers
You also may want to remove or disable the discount code option after a specific period of time or for a particular customer group.

How to Remove ‘Apply Discount Code’ from Checkout in Magento 2?

By default, the ‘Apply Discount Code’ option is displayed on the payment step at the end of payment methods. There is no option to remove or disable this option from the backend configuration. However, we can do this programmatically. Following are the two methods to get this done.

Method 1: Using the CSS File

Enter the following 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

Navigate to the following path
app/design/frontend/VENDOR/THEME/Magento_Checkout/layout/checkout_index_index.xml
And enter the following 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 apply the following commands to flush the cache.
php bin/magento cache:clean
php bin/magento cache:flush
This will cause the code to take effect and the 'Apply Discount' option will be removed from the checkout page.

That’s all for this post. Should you have any questions, don’t hesitate to contact our Magento 2 experts.

Related Articles: