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

What are Net Sales? How to Calculate Your Net Sales?

In the world of business, understanding financial metrics is crucial for making informed decisions and…

1 day ago

Magento 2 Extensions Digest April 2024 (New Release & Updates)

Welcome to the MageComp Monthly Digest, where we bring you the latest updates, releases, and…

1 day ago

The ABCs of Geofencing: Definition, Features and Uses

In this era, businesses are always on the lookout for ways to engage with their…

2 days ago

How to Delete Product Variant in a Shopify Remix App using GraphQL Mutations?

Managing a Shopify store efficiently involves keeping your product catalog organized. This includes removing outdated…

3 days ago

6 Innovative Tools Revolutionizing E-Commerce Operations

E-commerce has transformed the way consumers shop for products and services and interact with businesses.…

5 days ago

How Upcoming Cookie Changes Will Affect Your E-commerce Website?

The e-commerce world is constantly in flux. New tech and strategies emerge daily to help…

5 days ago