Skip to content

Instantly share code, notes, and snippets.

@csavoronin
Last active October 8, 2019 05:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csavoronin/f23c034c1380b2c57bc086f9d0cdaf6b to your computer and use it in GitHub Desktop.
Save csavoronin/f23c034c1380b2c57bc086f9d0cdaf6b to your computer and use it in GitHub Desktop.
[~] {@24849}: Addons: Stores and pickup points: On the map, the pickup point was not selected. Fixed.
diff --git a/design/themes/responsive/templates/addons/rus_sdek/views/checkout/components/shippings/items/sdek.tpl b/design/themes/responsive/templates/addons/rus_sdek/views/checkout/components/shippings/items/sdek.tpl
index f0b313c28b..5fd6393ba6 100644
--- a/design/themes/responsive/templates/addons/rus_sdek/views/checkout/components/shippings/items/sdek.tpl
+++ b/design/themes/responsive/templates/addons/rus_sdek/views/checkout/components/shippings/items/sdek.tpl
@@ -1,4 +1,4 @@
-<label for="{$ids_prefix}office_{$group_key}_{$shipping_id}_{$store.Code}"
+<label for="office_{$group_key}_{$shipping_id}_{$store.Code}"
class="ty-one-store js-pickup-search-block {if $old_office_id == $store.Code || $store_count == 1}ty-sdek-office__selected{/if} "
>
<input
@@ -8,8 +8,12 @@
{if $old_office_id == $store.Code || $store_count == 1}
checked="checked"
{/if}
- id="{$ids_prefix}office_{$group_key}_{$shipping_id}_{$store.Code}"
class="cm-sdek-select-store ty-sdek-office__radio-{$group_key} ty-valign"
+ id="office_{$group_key}_{$shipping_id}_{$store.Code}"
+ data-ca-pickup-select-office="true"
+ data-ca-shipping-id="{$shipping_id}"
+ data-ca-group-key="{$group_key}"
+ data-ca-location-id="{$store.Code}"
/>
<div class="ty-sdek-store__label ty-one-store__label">
diff --git a/design/themes/responsive/templates/addons/rus_sdek/views/checkout/components/shippings/list_sdek.tpl b/design/themes/responsive/templates/addons/rus_sdek/views/checkout/components/shippings/list_sdek.tpl
index 6c9be02118..5b4b61b485 100644
--- a/design/themes/responsive/templates/addons/rus_sdek/views/checkout/components/shippings/list_sdek.tpl
+++ b/design/themes/responsive/templates/addons/rus_sdek/views/checkout/components/shippings/list_sdek.tpl
@@ -38,10 +38,7 @@
<div class="ty-checkout-select-store pickup__offices-wrapper visible-phone pickup__offices-wrapper--near-map">
{* List *}
<div class="litecheckout__fields-row litecheckout__fields-row--wrapped pickup__offices pickup__offices--list pickup__offices--list-no-height">
- {include file="addons/rus_sdek/views/checkout/components/shippings/items/sdek.tpl"
- store=$store
- ids_prefix="mobile_"
- }
+ {include file="addons/rus_sdek/views/checkout/components/shippings/items/sdek.tpl" store=$store}
</div>
{* End of List *}
</div>
@@ -89,10 +86,7 @@
data-ca-error-message-target-node=".pickup__offices--list"
>
{foreach $shipping.data.offices as $store}
- {include file="addons/rus_sdek/views/checkout/components/shippings/items/sdek.tpl"
- store=$store
- ids_prefix="std_"
- }
+ {include file="addons/rus_sdek/views/checkout/components/shippings/items/sdek.tpl" store=$store}
{/foreach}
</div>
{* End of List *}
diff --git a/design/themes/responsive/templates/addons/rus_sdek/views/checkout/components/shippings/map_and_list_sdek.tpl b/design/themes/responsive/templates/addons/rus_sdek/views/checkout/components/shippings/map_and_list_sdek.tpl
index fa20249cda..ce7813a2b4 100644
--- a/design/themes/responsive/templates/addons/rus_sdek/views/checkout/components/shippings/map_and_list_sdek.tpl
+++ b/design/themes/responsive/templates/addons/rus_sdek/views/checkout/components/shippings/map_and_list_sdek.tpl
@@ -58,10 +58,7 @@
<div class="ty-checkout-select-store pickup__offices-wrapper visible-phone pickup__offices-wrapper--near-map">
{* List *}
<div class="litecheckout__fields-row litecheckout__fields-row--wrapped pickup__offices pickup__offices--list pickup__offices--list-no-height">
- {include file="addons/rus_sdek/views/checkout/components/shippings/items/sdek.tpl"
- store=$store
- ids_prefix="mobile_"
- }
+ {include file="addons/rus_sdek/views/checkout/components/shippings/items/sdek.tpl" store=$store}
</div>
{* End of List *}
</div>
@@ -109,10 +106,7 @@
data-ca-error-message-target-node=".pickup__offices--list"
>
{foreach $shipping.data.offices as $store}
- {include file="addons/rus_sdek/views/checkout/components/shippings/items/sdek.tpl"
- store=$store
- ids_prefix="std_"
- }
+ {include file="addons/rus_sdek/views/checkout/components/shippings/items/sdek.tpl" store=$store}
{/foreach}
</div>
{* End of List *}
diff --git a/design/themes/responsive/templates/addons/store_locator/views/checkout/components/shippings/items/pickup.tpl b/design/themes/responsive/templates/addons/store_locator/views/checkout/components/shippings/items/pickup.tpl
index 13c100d995..64383adece 100644
--- a/design/themes/responsive/templates/addons/store_locator/views/checkout/components/shippings/items/pickup.tpl
+++ b/design/themes/responsive/templates/addons/store_locator/views/checkout/components/shippings/items/pickup.tpl
@@ -1,4 +1,4 @@
-<label for="{$ids_prefix}store_{$group_key}_{$shipping.shipping_id}_{$store.store_location_id}"
+<label for="store_{$group_key}_{$shipping.shipping_id}_{$store.store_location_id}"
class="ty-one-store js-pickup-search-block {if ($old_store_id == $store.store_location_id) || ($store_count == 1)}ty-sdek-office__selected{/if}"
>
<input type="radio"
@@ -8,7 +8,11 @@
{if ($old_store_id == $store.store_location_id) || ($store_count == 1)}
checked="checked"
{/if}
- id="{$ids_prefix}store_{$group_key}_{$shipping.shipping_id}_{$store.store_location_id}"
+ id="store_{$group_key}_{$shipping.shipping_id}_{$store.store_location_id}"
+ data-ca-pickup-select-store="true"
+ data-ca-shipping-id="{$shipping.shipping_id}"
+ data-ca-group-key="{$group_key}"
+ data-ca-location-id="{$store.store_location_id}"
/>
<div class="ty-sdek-store__label ty-one-store__label">
diff --git a/design/themes/responsive/templates/addons/store_locator/views/checkout/components/shippings/list_pickup.tpl b/design/themes/responsive/templates/addons/store_locator/views/checkout/components/shippings/list_pickup.tpl
index 7192e5b745..659df552cb 100644
--- a/design/themes/responsive/templates/addons/store_locator/views/checkout/components/shippings/list_pickup.tpl
+++ b/design/themes/responsive/templates/addons/store_locator/views/checkout/components/shippings/list_pickup.tpl
@@ -8,10 +8,7 @@
<div class="ty-checkout-select-store pickup__offices-wrapper visible-phone pickup__offices-wrapper--near-map">
{* List *}
<div class="litecheckout__fields-row litecheckout__fields-row--wrapped pickup__offices pickup__offices--list pickup__offices--list-no-height">
- {include file="addons/store_locator/views/checkout/components/shippings/items/pickup.tpl"
- store=$store
- ids_prefix="mobile_"
- }
+ {include file="addons/store_locator/views/checkout/components/shippings/items/pickup.tpl" store=$store}
</div>
{* End of List *}
</div>
@@ -55,10 +52,7 @@
data-ca-error-message-target-node=".pickup__offices--list"
>
{foreach from=$shipping.data.stores item=store}
- {include file="addons/store_locator/views/checkout/components/shippings/items/pickup.tpl"
- store=$store
- ids_prefix="std_"
- }
+ {include file="addons/store_locator/views/checkout/components/shippings/items/pickup.tpl" store=$store}
{/foreach}
</div>
{* End of List *}
diff --git a/design/themes/responsive/templates/addons/store_locator/views/checkout/components/shippings/map_and_list_pickup.tpl b/design/themes/responsive/templates/addons/store_locator/views/checkout/components/shippings/map_and_list_pickup.tpl
index 7f6560edb5..21161aab14 100644
--- a/design/themes/responsive/templates/addons/store_locator/views/checkout/components/shippings/map_and_list_pickup.tpl
+++ b/design/themes/responsive/templates/addons/store_locator/views/checkout/components/shippings/map_and_list_pickup.tpl
@@ -73,10 +73,7 @@
<div class="ty-checkout-select-store pickup__offices-wrapper visible-phone pickup__offices-wrapper--near-map">
{* List *}
<div class="litecheckout__fields-row litecheckout__fields-row--wrapped pickup__offices pickup__offices--list pickup__offices--list-no-height">
- {include file="addons/store_locator/views/checkout/components/shippings/items/pickup.tpl"
- store=$store
- ids_prefix="mobile_"
- }
+ {include file="addons/store_locator/views/checkout/components/shippings/items/pickup.tpl" store=$store}
</div>
{* End of List *}
</div>
@@ -120,10 +117,7 @@
data-ca-error-message-target-node=".pickup__offices--list"
>
{foreach from=$shipping.data.stores item=store}
- {include file="addons/store_locator/views/checkout/components/shippings/items/pickup.tpl"
- store=$store
- ids_prefix="std_"
- }
+ {include file="addons/store_locator/views/checkout/components/shippings/items/pickup.tpl" store=$store}
{/foreach}
</div>
{* End of List *}
diff --git a/js/addons/rus_sdek/map.js b/js/addons/rus_sdek/map.js
index adab51cb7a..e6900ac82c 100644
--- a/js/addons/rus_sdek/map.js
+++ b/js/addons/rus_sdek/map.js
@@ -40,30 +40,19 @@
location = $jelm.data('caLocationId'),
group_key = $jelm.data('caGroupKey'),
shipping_id = $jelm.data('caShippingId'),
- $shipping_item_elm = $('#office_' + group_key + '_' + shipping_id + '_' + location),
- delete_dummy_elm_after_calculate = false,
target_map_id = $jelm.data('caTargetMapId'),
$container = $('#' + target_map_id);
- // this workaround is required for checkboxes (offices) that are loaded by ajax request
- // and might not be present at the moment in the DOM tree
- if (!$shipping_item_elm.length) {
- delete_dummy_elm_after_calculate = true;
- $shipping_item_elm = $('<input>')
- .addClass('hidden')
- .attr('type', 'radio')
- .attr('name', 'select_office[' + group_key + '][' + shipping_id + ']')
- .val(location);
- $('#sdek_offices').append($shipping_item_elm);
- }
+ $('[data-ca-pickup-select-office]' +
+ '[data-ca-shipping-id="' + shipping_id + '"]' +
+ '[data-ca-group-key="' + group_key + '"]' +
+ '[data-ca-location-id="' + location + '"]').each(function () {
+ $(this).prop('checked', true);
+ });
- $shipping_item_elm.prop('checked', true);
fn_calculate_total_shipping_cost();
$container.ceGeoMap('exitFullscreen');
- if (delete_dummy_elm_after_calculate) {
- $shipping_item_elm.remove();
- }
});
});
})(Tygh, Tygh.$);
diff --git a/js/addons/store_locator/pickup.js b/js/addons/store_locator/pickup.js
index b11471c830..c067d40705 100644
--- a/js/addons/store_locator/pickup.js
+++ b/js/addons/store_locator/pickup.js
@@ -47,7 +47,13 @@
group_key = $jelm.data('caGroupKey'),
shipping_id = $jelm.data('caShippingId');
- $('#store_' + group_key + '_' + shipping_id + '_' + location).prop('checked', true);
+ $('[data-ca-pickup-select-store]' +
+ '[data-ca-shipping-id="' + shipping_id + '"]' +
+ '[data-ca-group-key="' + group_key + '"]' +
+ '[data-ca-location-id="' + location + '"]').each(function () {
+ $(this).prop('checked', true);
+ });
+
fn_calculate_total_shipping_cost();
});
});
diff --git a/js/addons/yandex_delivery/yandex.js b/js/addons/yandex_delivery/yandex.js
index 06011e0fae..bbfc9bf183 100644
--- a/js/addons/yandex_delivery/yandex.js
+++ b/js/addons/yandex_delivery/yandex.js
@@ -204,8 +204,13 @@
if (maps[group_key]) {
maps[group_key].destroy();
}
-
- $('#store_' + group_key + '_' + shipping_id + '_' + location).prop("checked", true);
+
+ $('[data-ca-pickup-select-store]' +
+ '[data-ca-shipping-id="' + shipping_id + '"]' +
+ '[data-ca-group-key="' + group_key + '"]' +
+ '[data-ca-location-id="' + location + '"]').each(function () {
+ $(this).prop('checked', true);
+ });
fn_calculate_total_shipping_cost();
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment