3

How do I remove the discount code from the cart ? There are loads of examples of how to remove it from the checkout but I also need to remove it from the cart.

3 Answers 3

12

app/design/frontend/{Vendor}/{theme}/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>
        <referenceContainer name="cart.discount" remove="true"/>
    </body>
</page>
3
  • 1
    I got '[ERROR] Failed to load the "Magento_GiftMessage/js/view/gift-message" component.' js error when use this code
    – himansu
    Oct 21, 2018 at 17:03
  • On which version this solution have been tested? Jul 10, 2019 at 7:43
  • This only works on the Community edition of the Magento and will not work on Commerce as for Commerce GiftCardAccount is actually using this container so it will throw error as mentioned by @himansu Sep 10, 2020 at 1:40
0

create new file at app/design/frontend/{Vendor}/{theme}/Magento_Checkout/layout/checkout_cart_index.xmland paste the below contents.

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <!-- remove discount form on shopping cart -->
        <referenceContainer name="checkout.cart.coupon" remove="true"/>
    </body>
</page>

flush the layout cache after doing the modification.

0

Try this,

VendorName/ModuleName/view/frontend/layout/checkout_cart_index.xml

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

Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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