5

I want to remove shipping method from the cart page and checkout page.

I am trying to remove the shipping method from checkout page but seems it's loading from the Knockout.js file.

How can i remove the shipping method from the checkout page or hide it and show my custom message "For shipping Call ME" instead of shipping method.
Also, my store is multi language so message should display in multi language.

4

If you are not select shipping method then you are not able to place the order. Any way to achieve your task you need to follow this step:

Vendor: Vendor

ModuleName: CheckoutStep

1) Override checkout_index_index.xml in your module and define your own component in shipping step

app/code/Vendor/CheckoutStep/view/frontend/layout/checkout_index_index.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" 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="shipping-step" xsi:type="array">
                                            <item name="children" xsi:type="array">
                                                <item name="shippingAddress" xsi:type="array">
                                                    <item name="component" xsi:type="string">Vendor_CheckoutStep/js/view/krish-shipping</item>
                                                </item>
                                            </item>
                                        </item>
                                    </item>
                                </item>
                            </item>
                        </item>
                    </item>
                </argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

2) Create krish-shipping.js and define your own shipping template

define(
    [
        'jquery',
        'ko',
        'Magento_Checkout/js/view/shipping'
    ],
    function(
        $,
        ko,
        Component
    ) {
        'use strict';
        return Component.extend({
            defaults: {
                template: 'Vendor_CheckoutStep/shipping'
            },

            initialize: function () {
                var self = this;
                this._super();
            }

        });
    }
); 

3) Copy shipping.html

From

vendor/magento/module-checkout/view/frontend/web/template/shipping.html

To

app/code/Vendor/CheckoutStep/view/frontend/web/template/shipping.html

3) Remove html after class checkout-shipping-method and add Your message

<!--Shipping method template-->
<li id="opc-shipping_method"
    class="checkout-shipping-method"
    data-bind="fadeVisible: visible(), blockLoader: isLoading"
    role="presentation">
    <div class="checkout-shipping-method">
    <div class="step-title" data-bind="i18n: 'Shipping Methods'" data-role="title"></div>
        <div data-bind="i18n: 'Your Custom Message'" data-role="title"></div>
    </div>
</li>

Follow this ans if you want to disable particular shipping method: Link

  • Thanks for your reply. Yes i know without shipping it will not process the order but what i have done is i have enabled free shipping and using observer i have freeshipping all the time. i want to remove shipping from checkout or hide and show my custom message. your code hide the shipping or remove it? – jack May 19 '17 at 6:46
  • In step 3 you keep html of shipping method if you want just hide add class to hide shipping method – Prince Patel May 19 '17 at 6:56
  • Hi @Prince Patel, I have followed the same as above but i am unable to get what is exptected. – Learing_Coder May 2 '18 at 13:10
  • I tried this code but it's not working – kiran Sep 27 '18 at 14:00
  • how can i use customer group wise display free shipping if you know please reply me – Rv Singh Nov 13 '18 at 14:35

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.