0

I want to display a custom message before the shipping methods load and hide that message after shipping methods loading done. How can I do that?

  • Do you need custom message already available at checkout and hide it when shipping methods load OR it would be shown when shipping methods load triggered and hidden after load? – Himmat Paliwal Nov 29 '18 at 9:34
  • @HimmatPaliwal Yes i want to display custom message when shipping methods loading like "Please wait shipping methods loading" and hide that message after loading done – Mukesh Prajapati Nov 29 '18 at 9:46
0

You can play with

Magento_Checkout/js/model/shipping-service.js

Magento_Checkout/js/view/shipping.js

/Magento_Checkout/js/action/select-shipping-method.js

These js files triggers when shipping methods loaded.

Update:

Please override below file in your custom theme

/Magento_Checkout/js/action/select-shipping-method.js

and add below code:

define([
    'jquery',
    '../model/quote'
], function ($, quote) {
    'use strict';

    return function (shippingMethod) {
        $('.msg-wrapper').show();
        quote.shippingMethod(shippingMethod);
        $('.msg-wrapper').hide();
    };
});

You have to create a container with class "msg-wrapper" having the required message to show while methods loading. It would be shown when method loads and hidden once loaded.

To test the above, you can add simple alert by using below code in

app/design/frontend/package/theme/Magento_Checkout/web/js/action/select-shipping-method.js

define([
    'jquery',
    '../model/quote'
], function ($, quote) {
    'use strict';

    return function (shippingMethod) {
        alert('Please wait shipping methods loading');
        quote.shippingMethod(shippingMethod);
        alert('Shipping methods loaded');
    };
});

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.