Question

I made below in my theme, but new xml does not remove the git option block.

/app/design/frontend/Mytheme/themename/Magento_GiftMessage/Magento_GiftMessage/view/frontend/layout/checkout_cart_item_renderers.xml

and

/app/design/frontend/Mytheme/themename/Magento_GiftMessage/Magento_GiftMessage/view/frontend/layout/checkout_cart_index.xml

the xml is:

<page 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.order.actions.gift_options" remove="true"/>
    </body>
</page>
Was it helpful?

Solution

You have to use

/app/design/frontend/Mytheme/themename/Magento_GiftMessage/layout/checkout_cart_index.xml

and

/app/design/frontend/Mytheme/themename/Magento_GiftMessage/layout/checkout_cart_item_renderers.xml

use Magento_GiftMessage only once not twice and don't need view/frontend.

OTHER TIPS

If you don't need this functionallity at all, another option would be to disable the module output:

  • Just go to Stores > Configuration > Advanced > Advanced
  • Search for Magento_GiftMessage
  • Disable it and clear cache

A much better approach is simply to disable this feature rather than edit code or disable the module output.

  1. On the Admin sidebar, tap Stores. Then under Settings, choose Configuration.
  2. In the panel on the left, under Sales, choose Sales.
  3. Expand the Gift Options section.
  4. If necessary, clear the Use system value checkbox. Then, do the following: a. If the setting is for a specific store view, choose the store view where the configuration applies. b. When prompted, tap OK to continue.
  5. Set the Gift Message options according to your preference: Allow Gift Messages on Order Level Allow Gift Messages for Order Items
  6. When complete, tap Save Config.

For more details see the Magento User Guide: http://docs.magento.com/m2/ce/user_guide/sales/checkout-gift-options.html

For Magento 2.4.0:

In app/design/frontend/YourVendor/yourtheme/Magento_Checkout/layout/checkout_cart_index.xml

<referenceBlock name="checkout.cart.giftcardaccount" remove="true"/>
<referenceBlock name="checkout.cart.item.renderers.default.actions.gift_options" remove="true"/>
<referenceBlock name="checkout.cart.item.renderers.simple.actions.gift_options" remove="true"/>
<referenceBlock name="checkout.cart.item.renderers.bundle.actions.gift_options" remove="true"/>
<referenceBlock name="checkout.cart.item.renderers.grouped.actions.gift_options" remove="true"/>
<referenceBlock name="checkout.cart.item.renderers.configurable.actions.gift_options" remove="true"/>
<referenceBlock name="checkout.cart.item.renderers.gift-card.actions.gift_options" remove="true"/>
<referenceBlock name="checkout.cart.order.actions.gift_options" remove="true"/>

I would have added this as a comment on Fabian Schmengler's correct answer, but I don't have the reputation to do it. If a moderator can move this that would be great.


Another reason why this really needs to be done via the admin instead of via XML is because removing the block will cause a Javascript error. More information can be seen on here, on the Magento issues tracker.

https://github.com/magento/magento2/issues/6983

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top