12

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?

18

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>
8
  • Happy I found this - my colleague obviously used this to hide the field, and I had to re-enable it now :-) – Andreas von Studnitz Mar 21 '18 at 7:36
  • What file do you put that CSS in @Chirag – Supplement May 1 '19 at 19:20
  • @Supplement You can write in your custom global CSS file. – chirag May 2 '19 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 – Supplement May 2 '19 at 21:44
  • 1
    add <referenceBlock name="checkout.cart.coupon" remove="true" /> in checkout_cart_index.xml file – chirag Jun 27 '19 at 10:44
7

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

1
  • 1
    Note you can just put this in your theme's default.xml if you don't want to create a module. – PedroKTFC May 12 '19 at 22:02
2

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 – Alin Lupoiu Feb 15 '17 at 9:04
  • 1
    Themes no longer have a local.xml. – Liam Mitchell Jan 7 '19 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? – Nagaraju K Jun 27 '19 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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.