skip to Main Content

I want to completely disable shipping method while placing an order and add a custom shipping fee in magento 2. Can anyone tell me how to disable shipping method?

4

Answers


  1. To disable any shipping method like flat rate: Goto Admin > Store > Configuration > Click on Shipping methods under Sales tab, it will show you all methods. Here you can disabled any method by setting “Enabled” option to No and click save config button.enter image description here

    Login or Signup to reply.
  2. I think you need to use flat shipping method and set the fee to zero. Then you need to create a script to autoselect flat rate as shipping method as magento does not select a shipping method.

    Lastly, a front-end guy can hide the shipping part on the front end. A shipping method is crucial to an order in Magento. You would need one if you do not want to make core changes to magento.

    The following should help to select a shipping method:
    https://magento.stackexchange.com/a/161473

    Login or Signup to reply.
  3. You can simply set all products with zero weight.

    This will let all products into virtual product.

    And system will auto skip the shipping step.

    Login or Signup to reply.
  4. As you want to remove shipping method section completely but magento must need to assign one specific shipping method.
    Please follow following steps to remove shipping method completely and assign automatically specific shipping method (magento 2.3.1)

    Override these two files to your theme folder

    1. /vendor/magento/module-checkout/view/frontend/web/template/shipping.html
    2. /vendor/magento/module-checkout/view/frontend/web/js/model/checkout-data-resolver.js

    On shipping.html file, remove entire code inside form except actions-toolbar div as it use for Next button.
    So your shipping.html file will be

    <li id="shipping" class="checkout-shipping-address" data-bind="fadeVisible: visible()">
    <div class="step-title" translate="'Shipping Address'" data-role="title" />
    <div id="checkout-step-shipping"
         class="step-content"
         data-role="content">
    
        <each if="!quoteIsVirtual" args="getRegion('customer-email')" render="" />
        <each args="getRegion('address-list')" render="" />
        <each args="getRegion('address-list-additional-addresses')" render="" />
    
        <!-- Address form pop up -->
        <if args="!isFormInline">
            <button type="button"
                    class="action action-show-popup"
                    click="showFormPopUp"
                    visible="!isNewAddressAdded()">
                <span translate="'New Address'" />
            </button>
            <div id="opc-new-shipping-address"
                 visible="isFormPopUpVisible()"
                 render="shippingFormTemplate" />
        </if>
    
        <each args="getRegion('before-form')" render="" />
    
        <!-- Inline address form -->
        <render if="isFormInline" args="shippingFormTemplate" />
    </div>
    </li>
    
    <!--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 id="checkout-step-shipping_method"
             class="step-content"
             data-role="content"
             role="tabpanel"
             aria-hidden="false">
            <form id="co-shipping-method-form"
                  class="form methods-shipping"
                  if="rates().length"
                  submit="setShippingInformation"
                  novalidate="novalidate">
    
    
    
    
    
                <div class="actions-toolbar" id="shipping-method-buttons-container">
                    <div class="primary">
                        <button data-role="opc-continue" type="submit" class="button action continue primary">
                            <span translate="'Next'" />
                        </button>
                    </div>
                </div>
            </form>
    
        </div>
    </div>
    

    then, run s:s:d coomand and check checkout page, shipping method section should be removed.

    Now, as magento must require shipping method, we can assign static shipping methods from checkout-data-resolver.js file

    On checkout-data-resolver.js file, add following code on resolveShippingRates function

        if (ratesData.length === 1) {
    
                //set shipping rate if we have only one available shipping rate
                selectShippingMethodAction(ratesData[0]);
    
                return;
            }
    
           if (ratesData.length > 1) {
             selectShippingMethodAction(ratesData[0]);
                    return;
            }
    

    You can auto assign shipping method like ratesData[0], ratesData[1],ratesData[2] as per requirement

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search