Magento – Magento 2 – Table Rate shipping method not showing in cart & checkout page

magento2shipping-methodsshipping-taxshopping-carttable-rates

I am using the Magento 2.3.1 for my store. I just only enabled Table Rate shipping method with Price Vs Destination.

After that I exported the sample format & updated country, zone values with shipping amount. Finally imported & saved the configuration and cleared cache.

But when I add to the product & checked the Cart & Checkout page but still the table rate value as 0 even I have selected proper Country & State.

Here is my imported csv file.

enter image description here

Can anyone let me know what's the issue?

Best Answer

I finally figured out the issue.

The code to check the shipping method to show is in the template file vendor/magento/module-checkout/view/frontend/web/template/shipping.html

...
    <div class="checkout-shipping-method">
        <div class="step-title" data-bind="i18n: 'Shipping Methods'" data-role="title"></div>
        <!-- ko foreach: getRegion('before-shipping-method-form') -->
        <!-- ko template: getTemplate() --><!-- /ko -->
        <!-- /ko -->
        <div id="checkout-step-shipping_method"
             class="step-content"
             data-role="content"
             role="tabpanel"
             aria-hidden="false">
            <!-- ko if: rates().length  -->
            <form class="form methods-shipping" id="co-shipping-method-form" data-bind="submit: setShippingInformation" novalidate="novalidate">
                <div id="checkout-shipping-method-load">
...
            </form>
            <!-- /ko -->
            <!-- ko ifnot: rates().length > 0 --><div class="no-quotes-block"><!-- ko i18n: 'Sorry, no quotes are available for this order at this time'--><!-- /ko --></div><!-- /ko -->
        </div>
    </div>
...

See Below code

<!-- ko if: rates().length  -->

Above code review rate avaliable or not . If have then show shipping method and rate

The available rates is getting from the view vendor/magento/module-checkout/view/frontend/web/js/view/shipping.js

/** * Shipping Method View */ rates: shippingService.getShippingRates(),

The logic Magento 2 to set shipping rates is beyond this single post, but you can check more details in

vendor/magento/module-checkout/view/frontend/web/js/model/shipping-rate-processor/new-address.js
vendor/magento/module-checkout/view/frontend/web/js/model/shipping-rate-processor/customer-address.js

Focus on lines related to

shippingService.setShippingRates(...)

My case, there was an extension that overrides the shipping view of default Magento

vendor/magento/module-checkout/view/frontend/web/js/view/shipping.js
=>

it is overridden by another extension

And in the code of that extension, it checks one more condition to show only shipping methods it allows, so the default Flat Rate returned but it is not in the allowed shipping method, then nothing showed!

Related Topic