15

I tried to hide the Discount Code field from checkout payment page, but i can't find anything in xml files.

For cart page, i found this field in checkout_cart_index.xml, and i was able to hide like this:

 <block class="Magento\Checkout\Block\Cart\Coupon" name="checkout.cart.coupon" as="coupon" template="cart/coupon.phtml"/> <referenceBlock name="checkout.cart.coupon" remove="true"/> 

Does anyone know how this field it's add on the payment page? or from where i can deleted?

6 Answers 6

24

Use below CSS for hiding discount block.

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

Edit

app/code/vendor/Module/view/frontend/layout/checkout_index_index.xml

or

app/design/frontend/Vendor/theme/Magento_Checkout/layout/checkout_index_index.xml

you can also remove discount block using 'checkout_index_index.xml'

@Prashant is also correct;

<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="checkout" 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> </page> 
11
  • Happy I found this - my colleague obviously used this to hide the field, and I had to re-enable it now :-) Commented Mar 21, 2018 at 7:36
  • What file do you put that CSS in @Chirag Commented May 1, 2019 at 19:20
  • @Supplement You can write in your custom global CSS file. Commented May 2, 2019 at 8:31
  • So this would be in like that same directory structure but inside web/css/global.css? Can you elaborate a bit more on this topic.. like the exact directory structure and would the name just be "global.css" which resides in whatever directory? @chirag Commented May 2, 2019 at 21:44
  • 1
    add <referenceBlock name="checkout.cart.coupon" remove="true" /> in checkout_cart_index.xml file Commented Jun 27, 2019 at 10:44
9

Add checkout_index_index.xml at your custom module app/code/vendor/Module/view/frontend/layout/checkout_index_index.xml

Add below code to it.

<?xml version="1.0"?> <!-- /** * Copyright © 2016 Magento. All rights reserved. * See COPYING.txt for license details. */ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" 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> </page> 

In above code You find below code through this I have removed item discount :

<item name="discount" xsi:type="array"> <item name="config" xsi:type="array"> <item name="componentDisabled" xsi:type="boolean">true</item> </item> </item> 

Also refer for more information

2
  • 2
    Note you can just put this in your theme's default.xml if you don't want to create a module. Commented May 12, 2019 at 22:02
  • This code worked for me in my child theme's default.xml, so an upvote to @PedroKTFC too. Thanks guys. Commented Mar 17, 2023 at 11:35
3

override checkout_cart_index.xml file

and last line remove coupon code block

Move from app/design/frontend/V/T/Magento_checkout/layout/checkout_cart_index.xml

 <?xml version="1.0"?> <page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> ..... ..... <referenceBlock name="checkout.cart.coupon" remove="true"/> </body> </page> 
0

In your theme's local.xml add the following code

<?xml version="1.0" encoding="UTF-8" ?> <layout> <checkout_cart_index> <reference name="content"> <remove name="checkout.cart.coupon"/> </reference> </checkout_cart_index> </layout> 

It will remove discount coupon.

2
  • it's for checkout payment page? i think this it's for cart page, no checkout payment page Commented Feb 15, 2017 at 9:04
  • 1
    Themes no longer have a local.xml. Commented Jan 7, 2019 at 23:58
0

Something like this also to remove Gift Card Options from checkout page. Generally it appears below discount coupon section.

app/design/frontend/Company/theme/Magento_GiftCardAccount/layout/checkout_index_index.xml

<?xml version="1.0"?><page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" 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="giftCardAccount" 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> 

This is very important

<item name="children" xsi:type="array"> <item name="giftCardAccount" xsi:type="array"> <item name="config" xsi:type="array"> <item name="componentDisabled" xsi:type="boolean">true</item> </item> </item> </item> 
1
  • how to remove coupon code block from cart page? Commented Jun 27, 2019 at 9:05
0

Add a file named "theme.xml" to app/design/frontend/Vendor/theme/ and add this text:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <head> <css src="css/style.css"/> </head> <body> <referenceBlock name="checkout.cart.coupon" remove="true" /> </body> </page> 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.