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

                    Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

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

                    Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form