2

On my checkout page I have Post(Online API) shipping method, in which I have many shipping points available, customer can choose whatever he want.

By default the first shipping point is selected, I want to remove this preselected thing and want customer to choose before placing the order.

Any tips??

I tried this https://www.magemonkeys.com/how-to-uncheck-default-shipping-method-magento-2/ but doesnt help

1 Answer 1

4

Try following way:

app/code/SR/MagentoCommunity/view/frontend/requirejs-config.js

var config = {
    config: {
        mixins: {
            'Magento_Checkout/js/model/checkout-data-resolver': {
                'SR_MagentoCommunity/js/mixin/checkout-data-resolver-mixin': true
            }
        }
    }
};

app/code/SR/MagentoCommunity/view/frontend/web/js/mixin/checkout-data-resolver-mixin.js

define([
    'Magento_Checkout/js/action/select-shipping-method'
], function (selectShippingMethodAction) {
        'use strict';
        return function (target) {
            target.resolveShippingRates = function(ratesData) {
                selectShippingMethodAction(null);
            };

            return target;
        }
    }
);

Clear browser js cache, remove pub/static if your magento mode is not developer. Clear cache.

6
  • I am getting this CRITICAL: Unable to resolve the source file for 'frontend/TEST/Theme/nb_NO/Mgento_Checkout/js/action/select-shipping-method.js'
    – Daniel_12
    Commented May 22, 2019 at 12:29
  • What is this 'frontend/TEST/Theme/nb_NO/Mgento_Checkout/js/action/select-shipping-method.js'?
    – Sohel Rana
    Commented May 22, 2019 at 12:31
  • This is wrong path.
    – Sohel Rana
    Commented May 22, 2019 at 12:32
  • I added your code in custom module and after enabling your code, am getting 404 for select-shipping-method.js on checkout page
    – Daniel_12
    Commented May 22, 2019 at 12:51
  • God knows how you add. This is working fine with fresh installation
    – Sohel Rana
    Commented May 22, 2019 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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