How To

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

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?

Click to rate this post!
[Total: 8 Average: 4.5]
Dhiren Vasoya

Dhiren Vasoya is a Director and Co-founder at MageComp, Passionate ?️ Certified Magento Developer?‍?. He has more than 9 years of experience in Magento Development and completed 850+ projects to solve the most important E-commerce challenges. He is fond❤️ of coding and if he is not busy developing then you can find him at the cricket ground, hitting boundaries.?

Recent Posts

How to Add Tooltip in Checkout Shipping Field in Magento 2?

Hello Magento Friends, In today’s blog, I will explain How to Add Tooltip in Checkout…

2 days ago

How to Integrate and Use MongoDB with Laravel?

MongoDB is a popular NoSQL database that offers flexibility and scalability when handling modern web…

3 days ago

NodeJS | Callback Function

In NodeJS, callbacks empower developers to execute asynchronous operations like reading files, handling requests, and…

4 days ago

How to Show SKU in Order Summary in Magento 2?

Hello Magento Friends, In today’s blog, we will learn How to Show SKU in Order…

6 days ago

Best Colors to Use for CTA Buttons

The "Buy Now" and "Add to Cart" buttons serve as the primary call-to-action (CTA) elements…

1 week ago

Magento 2: How to Save Custom Field Value to quote_address for Multi-Shipping Orders

Hello Magento Friends, In Magento 2, the checkout process allows customers to choose multiple shipping…

1 week ago