4

I am making a store that never intends to offer gift cards.

I'm stumped how to disable the "Apply Gift Card" form on the payment step of checkout.

There isn't a clear way to do this via the admin. Disabling just the block won't also disable the JavaScript that is pulled in - and that causes other problems.

This is for Magento 2 Enterprise Edition. Disabling just the Magento_GiftCard module seems potentially problematic because of the dependencies it is involved with.

4
  • The only option you have is to disable that module from using command or from your config.php file there is no option to disable it from admin settings, i had same issue and endded up same result. Did contact with magento support regarding its settings they also replied same, by the way i was using magento 2.2.0 EE Cloud. Commented Apr 4, 2018 at 18:17
  • That's the problem. Properly disabling the Magento_GiftCard module via command-line ("bin/magento module:disable Magento_GiftCard") is problematic because Magento_Enterprise, Magento_GiftCardImportExport, Magento_AdvancedCheckout, Magento_MultipleWishlist, Magento_PricePermissions and Magento_GiftCardStaging all depend on it. How one does that gracefully isn't clear to me.
    – jschrab
    Commented Apr 4, 2018 at 19:08
  • Confirmed the dependencies listed in the above comment are still there in Magento 2.3.3. Wild. A simple "Enable/Disable" is what Magento needs on this. Commented May 26, 2020 at 21:12
  • Why not only hide it using CSS? Commented Dec 15, 2021 at 16:05

2 Answers 2

10

To remove this from the checkout, create a file in your theme called checkout_index_index.xml

i.e. For the checkout page: Magento_Checkout/layout/checkout_index_index.xml

Add the following to it...

<?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.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>
</page>

#christmastree

Don't forget to clear the cache.

The checkout is using Magento's UI components, see Magento's devdocs for more info on how to customise the checkout.

1

This is the best way to completly solve this probleme :
Create a new Module then,Remove component from Checkout Page:
VendorName/ModuleName/view/frontend/layout/checkout_index_index.xml

<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.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>
</page>

Remove block from Cart Page: 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.summary">
            <referenceBlock name="checkout.cart.giftcardaccount" remove="true"/>
        </referenceContainer>
    </body>
</page>

**Remove Gift Card link from My Account sidebar** VendorName/ModuleName/view/frontend/layout/customer_account.xml
 <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <!-- Gift Card link -->
        <referenceBlock name="customer-account-navigation-gift-card-link" remove="true"/>
    </body>
</page>

follow: https://www.sudhanshubajaj.com/magento-commerce-how-to-remove-gift-card-option-from-cart-checkout-and-my-account/

Your Answer

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

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