Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save torunar/6f8069851204425fcc9e3f4f8f8c113a to your computer and use it in GitHub Desktop.
Save torunar/6f8069851204425fcc9e3f4f8f8c113a to your computer and use it in GitHub Desktop.
diff --git a/app/addons/rus_customer_geolocation/controllers/frontend/checkout.pre.php b/app/addons/rus_customer_geolocation/controllers/frontend/checkout.pre.php
index 4003c5061a..87845cff14 100644
--- a/app/addons/rus_customer_geolocation/controllers/frontend/checkout.pre.php
+++ b/app/addons/rus_customer_geolocation/controllers/frontend/checkout.pre.php
@@ -17,7 +17,7 @@ defined('BOOTSTRAP') or die('Access denied');
/** @var string $mode */
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
- if ($mode == 'update_steps' && isset($_REQUEST['user_data'])) {
+ if (($mode == 'update_steps' || $mode === 'customer_info') && isset($_REQUEST['user_data'])) {
/** @var \Tygh\Addons\RusCustomerGeolocation\RusCustomerGeolocation $rus_customer_geolocation */
$user_info = $_REQUEST['user_data'];
@@ -32,4 +32,4 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
])
->storeLocation(true);
}
-}
\ No newline at end of file
+}
diff --git a/app/addons/rus_customer_geolocation/Tygh/Addons/RusCustomerGeolocation/RusCustomerGeolocation.php b/app/addons/rus_customer_geolocation/Tygh/Addons/RusCustomerGeolocation/RusCustomerGeolocation.php
index a0f5c200ac..7fc9050b8c 100644
--- a/app/addons/rus_customer_geolocation/Tygh/Addons/RusCustomerGeolocation/RusCustomerGeolocation.php
+++ b/app/addons/rus_customer_geolocation/Tygh/Addons/RusCustomerGeolocation/RusCustomerGeolocation.php
@@ -338,7 +338,7 @@ class RusCustomerGeolocation
* @param array $array
* @param string $field
*
- * @return string Field value or empty string
+ * @return string|null Field value or null
*/
public function getLocationField($array, $field)
{
@@ -354,7 +354,7 @@ class RusCustomerGeolocation
}
}
- return '';
+ return null;
}
/**
diff --git a/design/themes/responsive/templates/addons/lite_checkout/components/steps/shipping_methods.tpl b/design/themes/responsive/templates/addons/lite_checkout/components/steps/shipping_methods.tpl
index fcf6d48933..66a56033b3 100644
--- a/design/themes/responsive/templates/addons/lite_checkout/components/steps/shipping_methods.tpl
+++ b/design/themes/responsive/templates/addons/lite_checkout/components/steps/shipping_methods.tpl
@@ -1,6 +1,6 @@
-<div class="litecheckout__step" id="litecheckout_step_shipping_methods">
+<div id="litecheckout_step_location">
<div class="litecheckout__location--wrapper">
- <h3 class="litecheckout__step-title">{__('block_shipping_methods')}</h3>
+ <h3 class="litecheckout__step-title">{__("block_shipping_methods")}</h3>
<div class="litecheckout__location">
@@ -52,9 +52,12 @@
</div>
</div>
+ <div id="litecheckout_autocomplete_dropdown" class="litecheckout__autocomplete-dropdown"></div>
+<!--litecheckout_step_location--></div>
+
+<div class="litecheckout__step" id="litecheckout_step_shipping_methods">
+
<div class="litecheckout__fields-row">
{include file="addons/lite_checkout/components/shipping_rates.tpl" no_form=true}
</div>
-
- <div id="litecheckout_autocomplete_dropdown" class="litecheckout__autocomplete-dropdown"></div>
<!--litecheckout_step_shipping_methods--></div>
diff --git a/js/addons/lite_checkout/script.js b/js/addons/lite_checkout/script.js
index 0bf1d4c228..7e1ff8afef 100644
--- a/js/addons/lite_checkout/script.js
+++ b/js/addons/lite_checkout/script.js
@@ -74,23 +74,27 @@
callback = callback || false;
var result = true,
- fields = [ $('#litecheckout_step_buyer'), $('#litecheckout_step_shipping_methods')];
-
- if (callback != false) {
- fields.forEach(function (elm) {
- result = result && elm.ceFormValidator('check'); // check
- elm.ceFormValidator('check', false); // notice
- });
- }
+ fields = [
+ $('#litecheckout_step_location'),
+ $('#litecheckout_step_buyer'),
+ $('#litecheckout_step_shipping_methods')
+ ];
if (callback === false) {
return result;
}
+ fields.forEach(function (elm) {
+ result = result && elm.ceFormValidator('check'); // check
+ elm.ceFormValidator('check', false); // notice
+ });
+
return callback(result);
},
- serialize_checkout: function () {
+ serialize_checkout: function (set_zipcode) {
+ set_zipcode = typeof set_zipcode === 'undefined' ? true : set_zipcode;
+
var city = $city.val(),
state = $state.val(),
country = $country.val(),
@@ -98,7 +102,8 @@
address = $address.val(),
phone = $phone.val(),
name = $name.val(),
- customer_notes = $notes.val();
+ customer_notes = $notes.val(),
+ zipcode = $zipcode.val();
var serialized_checkout = {
result_ids: 'litecheckout*,checkout_info*,checkout_order_info*',
@@ -128,14 +133,20 @@
serialized_checkout[$captcha.prop('name')] = $captcha.val();
}
+ if (set_zipcode) {
+ serialized_checkout.user_data.b_zipcode = serialized_checkout.user_data.s_zipcode = zipcode;
+ }
+
return serialized_checkout;
},
- update_shipping: function () {
+ update_shipping: function (set_zipcode) {
+ set_zipcode = typeof set_zipcode === 'undefined' ? true : set_zipcode;
+
$.ceAjax('request', fn_url(''), {
method: 'post',
caching: false,
- data: methods.serialize_checkout()
+ data: methods.serialize_checkout(set_zipcode)
});
},
@@ -177,7 +188,7 @@
$city.val(city);
$cityState.val(ui.item.label);
- setTimeout(methods.update_shipping, 100);
+ methods.update_shipping(false);
}
});
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment