16

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?

50

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>
  • Indeed, I kind of messed up the double <arguments> nodes. The heading still shows up though, the contents of the dropdown are empty now.. Any suggestions to completely remove it? – Timon de Groot Apr 29 '16 at 9:45
  • The heading is specified in the cart shipping template: /vendor/magento/module-checkout/view/frontend/templates/cart/shipping.phtml You can move that into your own template and remove the text from there. – Corefix Apr 29 '16 at 10:25
  • 1
    @TimondeGroot You can just only remove the title part from the template file, without create the layout xml file. In this way you can preserve the shipping calculation in the summary block, but hide the "Estimate Shipping costs and Tax" form. – Andrea Aug 13 '16 at 16:25
  • @Andrea I know, I tried updating this anwer telling that, but it got denied.. – Timon de Groot Aug 13 '16 at 16:41
  • 1
    The funny thing is that it does not remove the HTML. There is just a "display:none" added. The real proper solution is to rewrite the shipping-estimation.html in Magento_Checkout/js , and even better, rewrite shipping-estimation.js , to remove all that not useful used CPU time. – Pol Ravalitera Aug 29 '17 at 14:37
5

I also needed to get rid of the "Estimate Shipping costs and Tax" because of a conflict with a payment module.

If your only objective is to not show the block, why not use CSS? This worked for me:

.cart-container .cart-summary #block-shipping {
    display: none;
}

(Version: Magento 2.2.1)

  • Where to wite this css ?? – Manish Jun 15 '18 at 7:59
  • The best way is to use a custom CSS-file that overrides the css-code but doesn't require you to change the original code. There are many guides out there on how to do that. – storepeinture Jun 16 '18 at 8:38
  • 1
    The best and optimal solution would be the layout way. If you apply a display:none the block still will be loading the js (using resources) – Beto Castillo Aug 3 '18 at 22:32
0

You can just add the following to checkout_cart_index.xml (in your custom theme, not core of course)

<referenceBlock name="checkout.cart.shipping" display="false"/>
-2

This method above works but I found it also removes the postage/shipping/delivery costs. This is a problem if you have shipping costs as it will not be added to the cart total (correct me if I'm wrong).

The method I used was to go into my style.css in my chosen theme folder and 'hide' the module.

#shipping-zip-form{
display:none !important;
}

This way you will still have the shipping cost option, but without the calculator. If you want to remove the title, follow the steps above. Personally, I renamed the title in my i18n file to say "Choose shipping method" instead of "Estimate shipping and tax". Not the most ideal method but definitely works best (considering functionality and less 'distructive') in my opinion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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