Magento 2: Recalculate shipping methods when State/Province changesHow to recalculate shipping costs in Magento one page checkoutError Message: the State and Province are not enteredShipping methods not showingState/Province (“Region”) Required field shipping checkout! MAGENTO2How to clear billing form validation errors when using Magento UI componentsCheckout shipping methods display default when only country is definedMagento 2 : How to change UI field(s) dynamicallypages loading slowMagento 2 : how can i add notice below state/province field in shipping address in checkout pageState/Province conditions not working on any of my rules

As easy as Three, Two, One... How fast can you go from Five to Four?

What is the language spoken in Babylon?

What did the 8086 (and 8088) do upon encountering an illegal instruction?

How do I type a hyphen in iOS 12?

Is Jesus the last Prophet?

Was the Lonely Mountain, where Smaug lived, a volcano?

Can I attach a DC blower to intake manifold of my 150CC Yamaha FZS FI engine?

If absolute velocity does not exist, how can we say a rocket accelerates in empty space?

Are skill challenges an official option or homebrewed?

Must I use my personal social media account for work?

Why would a car salesman tell me not to get my credit pulled again?

How to soundproof the Wood Shop?

Are athlete's college degrees discounted by employers and graduate school admissions?

What do I need to do, tax-wise, for a sudden windfall?

Is all-caps blackletter no longer taboo?

Purpose of cylindrical attachments on Power Transmission towers

Why did the Death Eaters wait to reopen the Chamber of Secrets?

A team managed by my peer is close to melting down

How do I properly use a function under a class?

Why are ambiguous grammars bad?

Keeping track of theme when improvising

Why would a home insurer offer a discount based on credit score?

Which are the methodologies for interpreting Vedas?

Is it advisable to add a location heads-up when a scene changes in a novel?



Magento 2: Recalculate shipping methods when State/Province changes


How to recalculate shipping costs in Magento one page checkoutError Message: the State and Province are not enteredShipping methods not showingState/Province (“Region”) Required field shipping checkout! MAGENTO2How to clear billing form validation errors when using Magento UI componentsCheckout shipping methods display default when only country is definedMagento 2 : How to change UI field(s) dynamicallypages loading slowMagento 2 : how can i add notice below state/province field in shipping address in checkout pageState/Province conditions not working on any of my rules






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















On step 1 (Shipping) of the checkout process, some of the fields - such as Zip/Postal Code - trigger re-evaluation of the list of available shipping methods.



I have a custom plugin in place that disables Free Shipping if the user chooses a non mainland-US state. Unfortunately, the "State/Province" select box does not trigger the AJAX call to "estimate-shipping-methods" which is needed to rebuild the list of shipping methods.



Does anyone know how to attach this event to the select box? I DON'T want a hacky answer like using jQuery to trigger onkeyup/onchange on one of the fields that already has the event attached to it.










share|improve this question






























    2















    On step 1 (Shipping) of the checkout process, some of the fields - such as Zip/Postal Code - trigger re-evaluation of the list of available shipping methods.



    I have a custom plugin in place that disables Free Shipping if the user chooses a non mainland-US state. Unfortunately, the "State/Province" select box does not trigger the AJAX call to "estimate-shipping-methods" which is needed to rebuild the list of shipping methods.



    Does anyone know how to attach this event to the select box? I DON'T want a hacky answer like using jQuery to trigger onkeyup/onchange on one of the fields that already has the event attached to it.










    share|improve this question


























      2












      2








      2








      On step 1 (Shipping) of the checkout process, some of the fields - such as Zip/Postal Code - trigger re-evaluation of the list of available shipping methods.



      I have a custom plugin in place that disables Free Shipping if the user chooses a non mainland-US state. Unfortunately, the "State/Province" select box does not trigger the AJAX call to "estimate-shipping-methods" which is needed to rebuild the list of shipping methods.



      Does anyone know how to attach this event to the select box? I DON'T want a hacky answer like using jQuery to trigger onkeyup/onchange on one of the fields that already has the event attached to it.










      share|improve this question
















      On step 1 (Shipping) of the checkout process, some of the fields - such as Zip/Postal Code - trigger re-evaluation of the list of available shipping methods.



      I have a custom plugin in place that disables Free Shipping if the user chooses a non mainland-US state. Unfortunately, the "State/Province" select box does not trigger the AJAX call to "estimate-shipping-methods" which is needed to rebuild the list of shipping methods.



      Does anyone know how to attach this event to the select box? I DON'T want a hacky answer like using jQuery to trigger onkeyup/onchange on one of the fields that already has the event attached to it.







      magento-2.1 checkout javascript






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 24 '17 at 21:03







      Geat

















      asked Aug 24 '17 at 21:00









      GeatGeat

      355217




      355217




















          1 Answer
          1






          active

          oldest

          votes


















          1














          After so much investigation I found one solution. I have tried for Offline shipping methods as described follows and its working fine for me:




          Namespace/Module/view/frontend/requirejs-config.js




          var config = 
          "map":
          "*":
          "Magento_OfflineShipping/js/model/shipping-rates-validation-rules/flatrate": "Namespace_Module/js/model/shipping-rates-validation-rules/flatrate",
          "Magento_OfflineShipping/js/model/shipping-rates-validation-rules/freeshipping": "Namespace_Module/js/model/shipping-rates-validation-rules/freeshipping",
          "Magento_OfflineShipping/js/model/shipping-rates-validation-rules/tablerate": "Namespace_Module/js/model/shipping-rates-validation-rules/tablerate"


          ;



          Namespace/Module/view/frontend/web/js/model/shipping-rates-validation-rules/flatrate.js




          define([], function () 
          'use strict';

          return
          /**
          * @return Object
          */
          getRules: function ()
          return
          'country_id':
          'required': true
          ,
          'city':
          'required': true
          ,
          'telephone':
          'required': true

          ;

          ;
          );



          Namespace/Module/view/frontend/web/js/model/shipping-rates-validation-rules/freeshipping.js




          define([], function () 
          'use strict';

          return
          /**
          * @return Object
          */
          getRules: function ()
          return
          'country_id':
          'required': true
          ,
          'city':
          'required': true
          ,
          'telephone':
          'required': true

          ;

          ;
          );



          Namespace/Module/view/frontend/web/js/model/shipping-rates-validation-rules/tablerate.js




          define([], function () 
          'use strict';

          return
          /**
          * @return Object
          */
          getRules: function ()
          return
          'postcode':
          'required': true
          ,
          'country_id':
          'required': true
          ,
          'region_id':
          'required': true
          ,
          'region_id_input':
          'required': true
          ,
          'city':
          'required': true
          ,
          'telephone':
          'required': true

          ;

          ;
          );


          These rules will automatically applied on change event of telephone and city fields.




          Note: I have tried for Offline shipping methods only. If you wan
          to do it for other shipping methods, then you can try in the same way.







          share|improve this answer























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "479"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f190504%2fmagento-2-recalculate-shipping-methods-when-state-province-changes%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            After so much investigation I found one solution. I have tried for Offline shipping methods as described follows and its working fine for me:




            Namespace/Module/view/frontend/requirejs-config.js




            var config = 
            "map":
            "*":
            "Magento_OfflineShipping/js/model/shipping-rates-validation-rules/flatrate": "Namespace_Module/js/model/shipping-rates-validation-rules/flatrate",
            "Magento_OfflineShipping/js/model/shipping-rates-validation-rules/freeshipping": "Namespace_Module/js/model/shipping-rates-validation-rules/freeshipping",
            "Magento_OfflineShipping/js/model/shipping-rates-validation-rules/tablerate": "Namespace_Module/js/model/shipping-rates-validation-rules/tablerate"


            ;



            Namespace/Module/view/frontend/web/js/model/shipping-rates-validation-rules/flatrate.js




            define([], function () 
            'use strict';

            return
            /**
            * @return Object
            */
            getRules: function ()
            return
            'country_id':
            'required': true
            ,
            'city':
            'required': true
            ,
            'telephone':
            'required': true

            ;

            ;
            );



            Namespace/Module/view/frontend/web/js/model/shipping-rates-validation-rules/freeshipping.js




            define([], function () 
            'use strict';

            return
            /**
            * @return Object
            */
            getRules: function ()
            return
            'country_id':
            'required': true
            ,
            'city':
            'required': true
            ,
            'telephone':
            'required': true

            ;

            ;
            );



            Namespace/Module/view/frontend/web/js/model/shipping-rates-validation-rules/tablerate.js




            define([], function () 
            'use strict';

            return
            /**
            * @return Object
            */
            getRules: function ()
            return
            'postcode':
            'required': true
            ,
            'country_id':
            'required': true
            ,
            'region_id':
            'required': true
            ,
            'region_id_input':
            'required': true
            ,
            'city':
            'required': true
            ,
            'telephone':
            'required': true

            ;

            ;
            );


            These rules will automatically applied on change event of telephone and city fields.




            Note: I have tried for Offline shipping methods only. If you wan
            to do it for other shipping methods, then you can try in the same way.







            share|improve this answer



























              1














              After so much investigation I found one solution. I have tried for Offline shipping methods as described follows and its working fine for me:




              Namespace/Module/view/frontend/requirejs-config.js




              var config = 
              "map":
              "*":
              "Magento_OfflineShipping/js/model/shipping-rates-validation-rules/flatrate": "Namespace_Module/js/model/shipping-rates-validation-rules/flatrate",
              "Magento_OfflineShipping/js/model/shipping-rates-validation-rules/freeshipping": "Namespace_Module/js/model/shipping-rates-validation-rules/freeshipping",
              "Magento_OfflineShipping/js/model/shipping-rates-validation-rules/tablerate": "Namespace_Module/js/model/shipping-rates-validation-rules/tablerate"


              ;



              Namespace/Module/view/frontend/web/js/model/shipping-rates-validation-rules/flatrate.js




              define([], function () 
              'use strict';

              return
              /**
              * @return Object
              */
              getRules: function ()
              return
              'country_id':
              'required': true
              ,
              'city':
              'required': true
              ,
              'telephone':
              'required': true

              ;

              ;
              );



              Namespace/Module/view/frontend/web/js/model/shipping-rates-validation-rules/freeshipping.js




              define([], function () 
              'use strict';

              return
              /**
              * @return Object
              */
              getRules: function ()
              return
              'country_id':
              'required': true
              ,
              'city':
              'required': true
              ,
              'telephone':
              'required': true

              ;

              ;
              );



              Namespace/Module/view/frontend/web/js/model/shipping-rates-validation-rules/tablerate.js




              define([], function () 
              'use strict';

              return
              /**
              * @return Object
              */
              getRules: function ()
              return
              'postcode':
              'required': true
              ,
              'country_id':
              'required': true
              ,
              'region_id':
              'required': true
              ,
              'region_id_input':
              'required': true
              ,
              'city':
              'required': true
              ,
              'telephone':
              'required': true

              ;

              ;
              );


              These rules will automatically applied on change event of telephone and city fields.




              Note: I have tried for Offline shipping methods only. If you wan
              to do it for other shipping methods, then you can try in the same way.







              share|improve this answer

























                1












                1








                1







                After so much investigation I found one solution. I have tried for Offline shipping methods as described follows and its working fine for me:




                Namespace/Module/view/frontend/requirejs-config.js




                var config = 
                "map":
                "*":
                "Magento_OfflineShipping/js/model/shipping-rates-validation-rules/flatrate": "Namespace_Module/js/model/shipping-rates-validation-rules/flatrate",
                "Magento_OfflineShipping/js/model/shipping-rates-validation-rules/freeshipping": "Namespace_Module/js/model/shipping-rates-validation-rules/freeshipping",
                "Magento_OfflineShipping/js/model/shipping-rates-validation-rules/tablerate": "Namespace_Module/js/model/shipping-rates-validation-rules/tablerate"


                ;



                Namespace/Module/view/frontend/web/js/model/shipping-rates-validation-rules/flatrate.js




                define([], function () 
                'use strict';

                return
                /**
                * @return Object
                */
                getRules: function ()
                return
                'country_id':
                'required': true
                ,
                'city':
                'required': true
                ,
                'telephone':
                'required': true

                ;

                ;
                );



                Namespace/Module/view/frontend/web/js/model/shipping-rates-validation-rules/freeshipping.js




                define([], function () 
                'use strict';

                return
                /**
                * @return Object
                */
                getRules: function ()
                return
                'country_id':
                'required': true
                ,
                'city':
                'required': true
                ,
                'telephone':
                'required': true

                ;

                ;
                );



                Namespace/Module/view/frontend/web/js/model/shipping-rates-validation-rules/tablerate.js




                define([], function () 
                'use strict';

                return
                /**
                * @return Object
                */
                getRules: function ()
                return
                'postcode':
                'required': true
                ,
                'country_id':
                'required': true
                ,
                'region_id':
                'required': true
                ,
                'region_id_input':
                'required': true
                ,
                'city':
                'required': true
                ,
                'telephone':
                'required': true

                ;

                ;
                );


                These rules will automatically applied on change event of telephone and city fields.




                Note: I have tried for Offline shipping methods only. If you wan
                to do it for other shipping methods, then you can try in the same way.







                share|improve this answer













                After so much investigation I found one solution. I have tried for Offline shipping methods as described follows and its working fine for me:




                Namespace/Module/view/frontend/requirejs-config.js




                var config = 
                "map":
                "*":
                "Magento_OfflineShipping/js/model/shipping-rates-validation-rules/flatrate": "Namespace_Module/js/model/shipping-rates-validation-rules/flatrate",
                "Magento_OfflineShipping/js/model/shipping-rates-validation-rules/freeshipping": "Namespace_Module/js/model/shipping-rates-validation-rules/freeshipping",
                "Magento_OfflineShipping/js/model/shipping-rates-validation-rules/tablerate": "Namespace_Module/js/model/shipping-rates-validation-rules/tablerate"


                ;



                Namespace/Module/view/frontend/web/js/model/shipping-rates-validation-rules/flatrate.js




                define([], function () 
                'use strict';

                return
                /**
                * @return Object
                */
                getRules: function ()
                return
                'country_id':
                'required': true
                ,
                'city':
                'required': true
                ,
                'telephone':
                'required': true

                ;

                ;
                );



                Namespace/Module/view/frontend/web/js/model/shipping-rates-validation-rules/freeshipping.js




                define([], function () 
                'use strict';

                return
                /**
                * @return Object
                */
                getRules: function ()
                return
                'country_id':
                'required': true
                ,
                'city':
                'required': true
                ,
                'telephone':
                'required': true

                ;

                ;
                );



                Namespace/Module/view/frontend/web/js/model/shipping-rates-validation-rules/tablerate.js




                define([], function () 
                'use strict';

                return
                /**
                * @return Object
                */
                getRules: function ()
                return
                'postcode':
                'required': true
                ,
                'country_id':
                'required': true
                ,
                'region_id':
                'required': true
                ,
                'region_id_input':
                'required': true
                ,
                'city':
                'required': true
                ,
                'telephone':
                'required': true

                ;

                ;
                );


                These rules will automatically applied on change event of telephone and city fields.




                Note: I have tried for Offline shipping methods only. If you wan
                to do it for other shipping methods, then you can try in the same way.








                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jun 6 at 6:48









                Dhara BhattiDhara Bhatti

                451112




                451112



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Magento Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f190504%2fmagento-2-recalculate-shipping-methods-when-state-province-changes%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                    Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

                    Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?