File: /home/retile.ru/public_html/catalog/view/theme/unishop2/template/checkout/uni_checkout.twig
{{ header }}
<div id="unicheckout" class="container">
<div class="breadcrumb-h1 {{ menu_expanded ? ' col-md-offset-3 col-lg-offset-3 col-xxl-offset-4' }}">
<ul class="breadcrumb mobile">
{% for key, breadcrumb in breadcrumbs %}
{% if key + 1 < breadcrumbs|length %}
<li><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li>
{% else %}
{% if not hide_last_breadcrumb or (hide_last_breadcrumb and key == 1) %}<li>{{ breadcrumb.text }}</li>{% endif %}
{% endif %}
{% endfor %}
</ul>
<h1 class="heading">{{ heading_title }}</h1>
</div>
<div id="content">
{{ content_top }}
<div class="uni-wrapper">
<div class="unicheckout__wrapper row">
<div class="unicheckout__forms col-sm-12 col-md-9 col-lg-9 col-xxl-15">
<div id="unicart">
{{ cart }}
</div>
{% if show_popup_login %}
<div class="checkout-login">{{ text_register2 }} <a onclick="uniLoginOpen();" class="checkout-login__link">{{ text_login2 }}</a></div>
{% endif %}
<form id="unicheckout__form" class="unicheckout__form">
<div class="unicheckout__user">
<h4>{{ text_your_details }}</h4>
<div class="user_data checkout-customer">
<div class="row-flex">
{{ custom_fields }}
<input type="text" name="firstname" value="{{ firstname }}" placeholder="{{ name_text }}" class="checkout-customer__input form-control full-width" />
<input type="text" name="lastname" value="{{ lastname }}" placeholder="{{ lastname_text }}" class="checkout-customer__input form-control full-width {{ show_lastname is empty ? ' hidden' }}" />
<input type="email" name="email" value="{{ email }}" placeholder="{{ email_text }}" class="checkout-customer__input form-control full-width {{ show_email is empty ? ' hidden' }}" />
<input type="tel" name="telephone" value="{{ telephone }}" placeholder="{{ phone_text }}" class="checkout-customer__input form-control full-width {{ show_phone is empty ? ' hidden' }}" />
</div>
<input type="hidden" name="fax" value="" />
</div>
<script>if($('.checkout-customer__input').not('.hidden').length%2) $('.checkout-customer__input').not('.hidden').last().addClass('full-width');</script>
<div class="checkout-customer__register {{ show_email is empty or checkout_passgen ? ' hidden' }}">
{% if customer_id is empty %}
<label class="checkout-customer__register-label input show-register-form" data-toggle="collapse" data-target=".checkout-customer__group-pass">
<input type="checkbox" name="add-new-customer" value="1" id="register_user" {{ checkout_guest == 0 ? ' checked="checked"' }} /><a>{{ text_register3 }}</a>
</label>
<div class="checkout-customer__group-pass collapse {{ checkout_guest == 0 ? ' in' }}">
<div class="form-group required">
<input type="password" name="password" value="" placeholder="{{ password_text }}" class="form-control" />
</div>
{% if show_password_confirm %}
<div class="form-group required">
<input type="password" name="password-confirm" value="" placeholder="{{ password_confirm_text }}" class="form-control" />
</div>
{% endif %}
</div>
{% endif %}
</div>
{% if customer_id is empty and customer_groups %}
<div class="checkout-customer__group hidden">
<label class="checkout-customer__group-label control-label">{{ entry_customer_group }}</label>
{% for customer_group in customer_groups %}
<label class="checkout-customer__group-item input">
<input type="radio" name="customer_group_id" value="{{ customer_group.customer_group_id }}" id="{{customer_group.customer_group_id}}" {{ customer_group.customer_group_id == customer_group_id ? ' checked="checked"' }} />{{ customer_group.name }}
</label>
{% endfor %}
</div>
{% endif %}
</div>
{% if pickup_items %}
<div class="heading">{{ text_pickup_heading }}</div>
<ul class="unicheckout__pickup-nav nav nav-tabs">
{% if default_method != 'pickup' and shipping_method %}
<li {{ selected_method == 'delivery' ? ' class="active"' }}><a href="#unicheckout-method-tab-1" class="unicheckout__delivery" data-toggle="tab">{{ text_pickup_shipping }}</a></li>
{% endif %}
<li {{ selected_method == 'pickup' ? ' class="active"' }}><a href="#unicheckout-method-tab-0" class="unicheckout__pickup" data-toggle="tab">{{ text_pickup_pickup }}</a></li>
{% if default_method == 'pickup' and shipping_method %}
<li {{ selected_method == 'delivery' ? ' class="active"' }}><a href="#unicheckout-method-tab-1" class="unicheckout__delivery" data-toggle="tab">{{ text_pickup_shipping }}</a></li>
{% endif %}
</ul>
<div class="tab-content">
<div id="unicheckout-method-tab-0" class="tab-pane {{ selected_method == 'pickup' ? ' active' }}">
{% if pickup_items|length > 1 %}
<select class="unicheckout__pickup-select form-control">
<!-- <option value="0">Выбрать пункт выдачи</option> -->
{% for key, item in pickup_items %}
<option value="{{ key }}" {{item.selected ? ' selected="selected"'}} >{{ item.title }}</option>
{% endfor %}
</select>
<br />
{% endif %}
{% for key, item in pickup_items %}
<div class="unicheckout__pickup-item unicheckout__pickup-item-{{ key }} {{ item.selected is empty ? ' hidden' }}">
<h5><strong>{{ item.title }}</strong></h5>
<div class="unicheckout__pickup-address">{{ item.address }}</div>
<div class="unicheckout__pickup-time-life">
<div class="unicheckout__pickup-time">
<span class="unicheckout__pickup-time-span">{{ text_pickup_time }}</span> {{ item.working_hours }}
</div>
<div class="unicheckout__pickup-life">
<span class="unicheckout__pickup-life-span">{{ text_pickup_life }}</span> {{ item.shelf_life }}
</div>
</div>
{% if item.map %}
<button class="unicheckout__pickup-btn btn btn-small btn-default" data-title="{{ item.title }}" data-map="{{ item.map }}">{{ button_map }}</button>
{% endif %}
</div>
{% endfor %}
</div>
<div id="unicheckout-method-tab-1" class="tab-pane {{ selected_method == 'delivery' ? ' active' }}">
{% endif %}
<div class="unicheckout__address payment-address">
{{ address }}
</div>
<div class="unicheckout__shipping {{ shipping_method is empty ? ' hidden' }} hidden">
{{ shipping_method }}
</div>
{% if pickup_items %}
</div>
</div>
{% endif %}
<div class="unicheckout__payment hidden">
{{ payment_method }}
</div>
<div class="unicheckout__comment">
<h4>{{ text_comment2 }}</h4>
<textarea name="comment" rows="3" class="checkout-comment form-control">{{ comment }}</textarea>
</div>
</form>
</div>
{{ totals }}
</div>
<div id="confirm">
<div class="payment col-sm-12 col-md-9 col-lg-9 col-xxl-15" style="padding:20px 0"></div>
</div>
</div>
{{ content_bottom }}
</div>
</div>
<script>
$.ajaxSetup({cache: false});
{% if pickup_items %}
$('.unicheckout__pickup-nav li a').on('click', function() {
$('html body').append('<div class="preloader"></div>');
const receipt_method = $(this).hasClass('unicheckout__pickup') ? ' pickup' : 'delivery';
$.post('index.php?route=checkout/uni_checkout/setReceiptMethod', {unicheckout_receipt_method: receipt_method}, () => {
uniShippingUpdate();
});
});
$('.unicheckout__pickup-select').on('change', function() {
const id = $(this).val();
$('.unicheckout__pickup-item').addClass('hidden');
$('.unicheckout__pickup-item-'+id).removeClass('hidden');
$.post('index.php?route=checkout/uni_checkout/setPickupItem', {unicheckout_pickup_item_id: id});
});
$('.unicheckout__pickup-btn').on('click', function(e) {
e.preventDefault();
uniModalWindow('unicheckout__pickup-map', 'lg', $(this).data('title'), $(this).data('map'))
});
{% endif %}
$('body').on('change', 'input[name=\'shipping_method\'], input[name=\'payment_method\'], .payment-address input[type=\'text\'], .payment-address input[type=\'radio\'], .payment-address input[type=\'checkbox\'], .payment-address textarea, select[name=\'address_id\'], select[name=\'zone_id\']', () => {
setTimeout(() => {
uniCheckoutUpdate();
}, 180);
});
$('body').on('change', '.checkout-customer__group-item', () => {
uniCustomFieldUpdate();
});
$('body').on('click', '#confirm_checkout', function() {
const form = '.unicheckout__wrapper',
data = $(form+' input[type=\'text\'], '+form+' input[type=\'tel\'], '+form+' input[type=\'email\'], '+form+' input[type=\'date\'], '+form+' input[type=\'datetime-local\'], '+form+' input[type=\'time\'], '+form+' input[type=\'password\'], '+form+' input[type=\'hidden\'], '+form+' input[type=\'checkbox\']:checked, '+form+' input[type=\'radio\']:checked, '+form+' textarea, '+form+' select').serialize();
$.ajax({
url: 'index.php?route=checkout/uni_checkout/validate',
type: 'post',
data: data,
dataType: 'json',
beforeSend: function() {
$('#confirm_checkout').button('loading');
},
complete: function() {
if($('.payment').html() == '') {
$('#confirm_checkout').button('reset');
}
},
success: function(json) {
$('#unicheckout .text-danger').remove();
if (json['error']) {
for (i in json['error']) {
form_error(form, i, json['error'][i]);
}
uniFlyAlert('danger', json['error']);
if(json['error']['minimum']) {
var alert_minimum = json['error']['minimum']+'<button type="button" class="close" data-dismiss="alert">×</button>';
if($('#unicart .alert').length) {
$('#unicart .alert').html(alert_minimum);
} else {
$('#unicart').prepend('<div class="alert alert-danger">'+alert_minimum+'</div>');
}
}
if($('#unicart .alert').length) {
uniScrollTo('#unicart .alert');
} else if ($('.input-warning:not(.checkout-sticky__confirm-input)').length) {
uniScrollTo('.input-warning:first');
}
}
$('.payment').html('');
var hideButtonConfirm = false;
if (json['success']) {
$('.payment').html(json['success']['payment']);
$('.payment .btn-primary').addClass('btn-lg');
dataLayer.push({
'ecommerce':{
'currencyCode':'{{ currency }}',
'purchase':{
'actionField':{
'id': json['success']['order_id'],
'goal_id': '{{ metric_taget_id }}'
},
'products': json['success']['products']
}
}
});
if (typeof(gtag) === 'function') {
gtag('event', 'purchase', {'transaction_id': json['success']['order_id'], 'currency': '{{ currency }}', 'items': json['success']['products']});
}
{% if metric_id and metric_target %}
if (typeof(ym) === 'function') {
ym({{ metric_id }}, 'reachGoal', '{{ metric_target }}');
} else {
new Function('yaCounter{{ metric_id }}.reachGoal(\''+{{ metric_target }}+'\')')();
}
{% endif %}
{% if analytic_category and analytic_action %}
if (typeof(gtag) === 'function') {
gtag('event', '{{ analytic_action }}', {'event_category': '{{ analytic_category }}'});
} else if (typeof(ga) === 'function') {
ga('send', 'event', '{{ analytic_category }}', '{{ analytic_action }}');
}
{% endif %}
if (!$('.payment h2, .payment p, .payment form, .payment input[type=\'radio\'], .payment input[type=\'checkbox\'], .payment select').length) {
$('.payment').css('display', 'none');
setTimeout(function() {
$('.payment #button-confirm, .payment input[type=\'button\'], .payment input[type=\'submit\'], .payment button, .payment a, .payment .btn-primary').click();
}, 300);
if($('.payment a').length) {
$('.payment a')[0].click();
}
} else {
hideButtonConfirm = true;
}
if ($('.payment form').length && $('.payment form').attr('action')) {
let form_action = $('.payment form').attr('action');
if(/paypal|robokassa|wayforpay|tinkoff/i.test(form_action)) {
$('.payment').css('display', 'none');
$('.payment .btn-primary').click();
}
} else {
hideButtonConfirm = true;
}
if(hideButtonConfirm) {
$('#confirm_checkout').hide();
uniScrollTo('#confirm .payment');
}
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
{% if mask_telephone %}
$('#unicheckout input[name=\'telephone\']').mask('{{ mask_telephone }}').data('start', 0).on('click', function() {
const start = $(this).val().indexOf('_');
if(!$(this).data('start')) $(this).data('start', start);
if(start == $(this).data('start')) $(this)[0].setSelectionRange(start, start);
});
{% endif %}
$('body').on('click', '#ll_cdek_map .btn.btn-block', () => {
setTimeout(() => {
uniCheckoutUpdate();
}, 200);
});
$('body').on('click', '#button-coupon', function() {
var form = '#unicheckout';
$.ajax({
url: 'index.php?route=extension/total/coupon/coupon',
type: 'post',
data: 'coupon=' + encodeURIComponent($('input[name=\'coupon\']').val()),
dataType: 'json',
beforeSend: function() {
$('#button-coupon').button('loading');
},
complete: function() {
$('#button-coupon').button('reset');
},
success: function(json) {
$('.text-danger').remove();
if (json['error']) {
form_error(form, 'coupon');
uniFlyAlert('danger', json['error']);
}
if (json['redirect']) {
uniCheckoutUpdate();
uniFlyAlert('success', '{{ text_coupon_success }}');
}
}
});
});
$('body').on('click', '#button-reward', function() {
var form = '#unicheckout';
$.ajax({
url: 'index.php?route=extension/total/reward/reward',
type: 'post',
data: 'reward=' + encodeURIComponent($('input[name=\'reward\']').val()),
dataType: 'json',
beforeSend: function() {
$('#button-reward').button('loading');
},
complete: function() {
$('#button-reward').button('reset');
},
success: function(json) {
$('.text-danger').remove();
if (json['error']) {
form_error(form, 'reward');
uniFlyAlert('danger', json['error']);
}
if (json['redirect']) {
uniCheckoutUpdate();
uniFlyAlert('success', '{{ text_reward_success }}');
}
}
});
});
$('body').on('click', '#button-voucher', function() {
var form = '#unicheckout';
$.ajax({
url: 'index.php?route=extension/total/voucher/voucher',
type: 'post',
data: 'voucher=' + encodeURIComponent($('input[name=\'voucher\']').val()),
dataType: 'json',
beforeSend: function() {
$('#button-voucher').button('loading');
},
complete: function() {
$('#button-voucher').button('reset');
},
success: function(json) {
$('.text-danger').remove();
if (json['error']) {
form_error(form, 'voucher');
uniFlyAlert('danger', json['error']);
}
if (json['redirect']) {
uniCheckoutUpdate();
uniFlyAlert('success', '{{ text_voucher_success }}');
}
}
});
});
function uniVoucherRemove(key) {
$.ajax({
url: $('base').attr('href')+'index.php?route=checkout/cart/remove',
type: 'post',
data: 'key='+key,
dataType: 'json',
success: function(json) {
$('#cart').load('index.php?route=common/cart/info #cart > *');
uniCheckoutUpdate();
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
function uniCheckoutUpdate() {
$('#confirm_checkout').show();
let status = $('.preloader:visible').length ? true : false, data = $('.payment-address input, .payment-address textarea, .payment-address select').serialize();
if(!status) {
$.ajax({
url: $('base').attr('href')+'index.php?route=checkout/uni_checkout/addressRender',
type: 'post',
cache: false,
data: data,
dataType: 'html',
beforeSend: function() {
$('html body').append('<div class="preloader"></div>');
},
success: function(html) {
$('.unicheckout__address').html(html);
uniShippingUpdate();
}
});
}
}
function uniShippingUpdate() {
let data = $('.shipping-method input[type=\'radio\']:checked').serialize();
$.ajax({
url: $('base').attr('href')+'index.php?route=checkout/uni_checkout/shippingRender',
type: 'post',
cache: false,
data: data,
dataType: 'html',
success: function(html) {
$('.unicheckout__shipping').html(html);
uniPaymentUpdate();
}
});
}
function uniPaymentUpdate() {
let data = $('.payment-method input[type=\'radio\']:checked').serialize();
$.ajax({
url: $('base').attr('href')+'index.php?route=checkout/uni_checkout/paymentRender',
type: 'post',
cache: false,
data: data,
dataType: 'html',
success: function(html) {
$('.unicheckout__payment').html(html);
//setTimeout(function() {
uniCartUpdate();
//}, 300);
}
});
}
function uniCartUpdate() {
let data = '';
$.ajax({
url: $('base').attr('href')+'index.php?route=checkout/uni_checkout/cartRender',
type: 'post',
cache: false,
data: data,
dataType: 'html',
success: function(html) {
$('#unicart').html(html);
$('.total_checkout h3 span span').html($('.checkout-cart__totals-text:last').text());
$('.payment').html('');
$('#confirm_checkout').button('reset');
uniTotalsUpdate();
}
});
}
function uniCustomFieldUpdate() {
let data = $('.checkout-customer__group input[type=\'radio\']:checked').serialize();
$.ajax({
url: $('base').attr('href')+'index.php?route=checkout/uni_checkout/customFieldRenderAccount',
type: 'post',
cache: false,
data: data,
dataType: 'html',
success: function(html) {
$('.unicheckout__custom-field').html(html);
}
});
}
function uniTotalsUpdate() {
$.get($('base').attr('href')+'index.php?route=checkout/uni_checkout/totalsRender', function(data) {
$('.unicheckout-sticky__wrapper').html($(data).find('.unicheckout-sticky__wrapper').html());
$('.preloader').remove();
});
}
</script>
{{ footer }}