Site icon MageComp Blog

Magento 2: How To configure Auto Select Shipping Methods when more than one shipping methods are available.

How To Auto Select Shipping Method When More Then One Shipping Method in Magento 2

Hello, Magento Folks,

We have already learned Magento 2: Hide Other Shipping Methods if Free Shipping is Available. Today I will explain to you about How To Configure Auto Select Shipping method in your Magento 2 store When more than one shipping methods are available.

In the busy world of technologies, here is an only element called Time which is very expensive. So, the lack of time plays an important role in the checkout process of your store so auto select shipping method is considered to be an essential time-saving option for all your customers. Therefore when you have multiple shipping methods available in your store make sure by default to auto select any one shipping method for better customer experience.

When you have only one shipping method available in your store then definitely by default one shipping method is selected at the checkout page so there is no need of any configuration. But when you have multiple shipping methods available in your store then by default any method is not selected at the checkout page.

So, when you need to configure by default auto select one shipping method then you need to do the following code. You can easily configure and make your customer experience better by following below easy steps.

1. You need to override core file in your theme

Copy Following file.

vendor\magento\module-checkout\view\frontend\web\js\model\checkout-data-resolver.js

Past to

app\design\frontend\Themes\Yourtheme\Magento_Chekout\web\js\model\checkout-data-resolver.js

Search below code:

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

Replace below code:

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

If you have completed the above instruction then you have successfully completed the configuration of auto select any one shipping method option by default in your Magento 2 store if multiple shipping methods are available in your store. Now you can give a better customer experience in your Magento 2 store in which there will be by default selection of shipping method if more than one shipping method is available in your store.

So, that was all for the day! With the help of this rich information, you can successfully achieve the task of auto select shipping method if multiple shipping methods are available in your store. If you face any issues while implementing, then contact our support team. We will be happy to help you.

Lastly, if you found this helpful, then let us know your valuable words in the comments below. Also, don’t forget to share this with your Magento development partners.

Happy Coding?

Exit mobile version