Magento 2 Cart – Remove ‘Estimate Shipping Costs and Tax’ from Cart

cartlayoutmagento2totals

I want to get rid of the "Estimate Shipping costs and Tax" block in the cart. The devdocs tell Disabling a component is the way to go, so I tried the following:

<body>
    <referenceBlock name="checkout.cart.shipping">
        <arguments>
            <argument name="jsLayout" xsi:type="array">
                <item name="components" xsi:type="array">
                    <item name="block-summary" xsi:type="array">

                        <!-- My custom part: -->
                        <item name="config" xsi:type="array">
                            <item name="componentDisabled" xsi:type="boolean">true</item>
                        </item>

                    </item>
                </item>
            </argument>
        </arguments>
    </referenceBlock>
</body>

No effect. Also tried:

<referenceBlock name="checkout.cart.shipping" remove="true"/>

This way, my totals block is totally empty.

Does anyone have suggestions?

Best Answer

I think you messed up some closing / opening tags and amount of them this code works:

<referenceBlock name="checkout.cart.shipping">
    <arguments>
        <argument name="jsLayout" xsi:type="array">
            <item name="components" xsi:type="array">
                <item name="block-summary" xsi:type="array">

                    <!-- My custom part: -->
                    <item name="config" xsi:type="array">
                        <item name="componentDisabled" xsi:type="boolean">true</item>
                    </item>

                </item>
            </item>
        </argument>
    </arguments>
</referenceBlock>

To remove the heading as well, override the template checkout/cart/shipping.phtml and comment/remove the following:

<div class="title" data-role="title">
    <strong id="block-shipping-heading" role="heading" aria-level="2">
        <?php /* @escapeNotVerified */ echo $block->getQuote()->isVirtual() ? __('Estimate Tax') : __('Estimate Shipping and Tax') ?>
    </strong>
</div>
Related Topic