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
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>
-
1I got '[ERROR] Failed to load the "Magento_GiftMessage/js/view/gift-message" component.' js error when use this code– himansuOct 21, 2018 at 17:03
-
-
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
create new file at app/design/frontend/{Vendor}/{theme}/Magento_Checkout/layout/checkout_cart_index.xml
and 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.
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!