Files
kupshop/web/common/templates/deliveries/delivery.GeisPoint.description.tpl
2025-08-02 16:30:27 +02:00

82 lines
3.1 KiB
Smarty

<div class="delivery-class" data-delivery-class="{$deliveryPrefix}[geispoint]">
{if $object.cart_description}
{$object.cart_description nofilter}
{/if}
{$info = $object->getInfo($object.zip)}
<div class="pos-rel">
<input type="hidden" name="{$deliveryPrefix}[geispoint_id]" value="{$info.id}">
<input name="{$deliveryPrefix}[delivery_geispoint_zip]" class="form-control" placeholder="PSČ, město" value="{$info.address}"
autocomplete="off">
<button type="button" class="delete-zip" title="{t}Smazat hledané PSČ, město{/t}"><span class="fc lightbox_close"></span>
</button>
</div>
<div data-reload="geispoint_{$object.id}" class="posta-info open">
{if $info.zip}
{if $info.id}
<input type="hidden" name="delivery_geispoint_valid" value="1">
<p><strong>{t}Zboží doručíme na pobočku:{/t}</strong></p>
<p><strong>{$info.name}</strong><br>
{$info.street}<br>{$info.zip} {$info.city}<br>
</p>
{else}
<p><strong>{t}Pobočka nenalezena{/t}</strong></p>
<p>{t}Na hledaném místě neexistuje žádná pobočka Geis Point.{/t}</p>
{/if}
{/if}
</div>
</div>
<script id="{$deliveryPrefix}[geispointSearch]" type="text/x-dot-template">
{literal}
<div class="ac-psc">
<ul>
{{? it.items.length > 0}}
{{~it.items :item :index}}
<li data-autocomplete-item="product" data-autocomplete-value="{{=item.value}}"
data-autocomplete-name="{{=item.zip}} {{=item.name}}">
<span>{{=item.zip}} {{=item.name}}</span>
</li>
{{~}}
{{??}}
<li>Pobočka nenalezena</li>
{{?}}
</ul>
</div>
{/literal}
</script>
<script>
wpj.onReady.push(function() {
var errNotFound = "{t}Pobočka nebyla nalezena. Vyberte prosím jinou pobočku, nebo změňte způsob dopravy.{/t}";
var $deliveryWrapper = $('[data-delivery-class="{$deliveryPrefix}[geispoint]"]');
var $input = $deliveryWrapper.find('input[name="{$deliveryPrefix}[delivery_geispoint_zip]"]');
var $inputId = $deliveryWrapper.find(`input[name="{$deliveryPrefix}[geispoint_id]"]`);
{literal}
$input.deliveryAutocomplete({
source: '{/literal}{path('kupshop_catalog_autocomplete_autocomplete', ['type' => 'delivery_geispoint'])}{literal}&term={{=it.value}}',
template: '#{/literal}{$deliveryPrefix|replace:'[':'\\\['|replace:']':'\\\]'}{literal}\\[geispointSearch\\]',
inputId: $inputId
});
$input.closest('form').on('success.form.bv', function(w, hasError) {
if ($input.is(':visible') && $input.parents(':hidden').length === 0) {
if (!$('[name="delivery_geispoint_valid"]').val()) {
window.alert(errNotFound);
if (typeof hasError !== "undefined") {
hasError.error = true;
}
setTimeout(function() {
$input.get(0).focus();
}, 100);
return false;
}
}
});
{/literal}
});
</script>