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

                    Grendel Contents Story Scholarship Depictions Notes References Navigation menu10.1093/notesj/gjn112Berserkeree

                    Log in Navigation menu

                    Invalid response line returned from server: HTTP/2 401 | ErrorPlease Please Help With Error 500 Internal Server Error after upgrading from 1.7 to 1.9Unable to place new customer orders in admin backendMagento - For “Manage Categories” Forbidden You do not have permission to access this documentHTTP ERROR 500 when using require(_once) app/Mage.phpMemcached causing Web Setup Wizard ErrorCould not create an acl object: Invalid XMLAn error occurred on the server. Please try to place the order againInvalid response line returned from server: HTTP/2 200 - message after update to 2.1.7Magento-CE 2.3.0 installation error on XamppMagento 2.2.6- After Migration all default Payment Methods are not working fine