2

I have below code to trigger a change in a shipping method price in this file: view/web/js/model/shipping-rates-validation-rules.js

define(
    [],
    function () {
        'use strict';
        return {
            getRules: function() {
                return {
                    'country_id': {
                        'required': true
                    },
                    'region_id': {
                        'required': true
                    },
                    'street': {
                        'required': true
                    }
                };
            }
        };
    }
)

Both country_id and region_id trigger a reload for the shipping method but street is not doing so.

  • Do you find a solution ? – Franck Garnier Nov 20 '19 at 13:02
  • The issue seems to be here vendor/magento/module-checkout/view/frontend/web/js/model/shipping-rates-validator.js on the each after the line if (element.component.indexOf('/group') !== -1) { the each is not triggered : $.each(element.elems(), function (index, elem) { – Franck Garnier Nov 20 '19 at 15:11
2

Here : vendor/magento/module-checkout/view/frontend/web/js/model/shipping-rates-validator.js

A quick and dirty to fix the street element which is a group of elements:

            setTimeout(function() {
                $.each(element.elems(), function (index, elem) {
                    self.bindHandler(elem);
                });
            }, 100);

An alternative to solve it:

            element.elems.subscribe(function(elems) {
                $.each(elems, function (index, elem) {
                    self.bindHandler(elem);
                });
            });
|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.