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;
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
add a comment |
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
add a comment |
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
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
magento-2.1 checkout javascript
edited Aug 24 '17 at 21:03
Geat
asked Aug 24 '17 at 21:00
GeatGeat
355217
355217
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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.
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
add a comment |
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.
add a comment |
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.
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.
answered Jun 6 at 6:48
Dhara BhattiDhara Bhatti
451112
451112
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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