Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ichaykin/219598e17e97ae907b65458d04e90658 to your computer and use it in GitHub Desktop.
Save ichaykin/219598e17e97ae907b65458d04e90658 to your computer and use it in GitHub Desktop.
diff --git a/design/themes/responsive/templates/views/checkout/components/profile_fields/s_country.tpl b/design/themes/responsive/templates/views/checkout/components/profile_fields/s_country.tpl
index 7bdf8cb..bc64ff3 100644
--- a/design/themes/responsive/templates/views/checkout/components/profile_fields/s_country.tpl
+++ b/design/themes/responsive/templates/views/checkout/components/profile_fields/s_country.tpl
@@ -3,6 +3,7 @@
<select data-ca-lite-checkout-field="user_data.s_country"
class="cm-country cm-location-shipping litecheckout__input litecheckout__input--selectable litecheckout__input--selectable--select"
data-ca-lite-checkout-element="country"
+ data-ca-lite-checkout-last-value="{$user_data.s_country}"
required
id="litecheckout_country"
>
diff --git a/js/tygh/checkout/lite_checkout.js b/js/tygh/checkout/lite_checkout.js
index cdbedc7..a662a3b 100644
--- a/js/tygh/checkout/lite_checkout.js
+++ b/js/tygh/checkout/lite_checkout.js
@@ -405,6 +405,10 @@
return;
}
+ if (!$city.length) {
+ methods.lockShippingMethodSelector();
+ }
+
$city.val('');
$city.focus();
}).on('keypress', function (e) {
@@ -419,11 +423,14 @@
var $state = methods.getElement('state'),
city = $city.val(),
state = $state.val(),
+ country = $country.val(),
lastSelectedCity = $city.data('caLiteCheckoutLastValue'),
- lastSelectedState = $state.data('caLiteCheckoutLastValue');
+ lastSelectedState = $state.data('caLiteCheckoutLastValue'),
+ lastSelectedCountry = $country.data('caLiteCheckoutLastValue');
var isCityChanged = city !== lastSelectedCity,
- isStateChanged = state !== lastSelectedState;
+ isStateChanged = state !== lastSelectedState,
+ isCountryChanged = country !== lastSelectedCountry;
var stateCode = '';
if ($state.data('caLiteCheckoutIsStateCodeContainer')) {
@@ -433,7 +440,7 @@
methods.unlockShippingMethodSelector();
- if (isCityChanged || isStateChanged) {
+ if (isCityChanged || isStateChanged || isCountryChanged) {
methods.setLocation(city, stateCode, state);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment