0

Magento2.2.7.

Want to auto select first shipping method while multiple shipping there or auto select while single method there on checkout page.

Already try this solution but not working for me.

  • please check bsscommerce.com/…. it is free and I used it as well! – Pawan Feb 27 at 12:10
  • @Pawan Thank you. But Want to auto select first shipping method while multiple shipping there – Shorabh Feb 27 at 12:19
  • there is option to select first one, please see screen shot of module. – Pawan Feb 27 at 12:19
  • @Shorabh,I am sure you were using any third party module if solution is not working as per your link.Please check my answer and let me know. – akgola Feb 27 at 13:45
2

You can use a ready made module, It is free and from BSS commerce.

https://bsscommerce.com/magento-2-preselect-shipping-payment-extension.html

Note: You can select shipping of your choice Or first one

I used above module in some of my project.

| improve this answer | |
1

You need to override core file in your theme

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

Override file in your theme : sendorname/theme/Magento_Chekout/web/js/checkout-data-resolver.js

and check line number 151 code

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

        return;
    }

You can see here this code check that if only one shipping method thaen automatic got selected.So you need to changed the conditon here that if more than one shipping method then first should be selected with below code

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

            return;
        }

Now Cache clear and go to checkout page ,you will see first shipping method will automatic got selected.

Note: If you are using any third party one step checkout module then you need to search same file to override in your theme.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.