You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
638 lines
21 KiB
638 lines
21 KiB
$(document).on('click', '.yamm .dropdown-menu', function (e) {
|
|
e.stopPropagation();
|
|
});
|
|
|
|
$(document).on('click', '.navbar-item__currency', function (e) {
|
|
e.preventDefault();
|
|
});
|
|
|
|
$(document).ready(function () {
|
|
$("#shop-categories").on('affix.bs.affix', function () {
|
|
$('.header-middle').css('margin-bottom', $("#shop-categories").css('height'));
|
|
});
|
|
$("#shop-categories").on('affix-top.bs.affix', function () {
|
|
$('.header-middle').css('margin-bottom', '0px');
|
|
});
|
|
|
|
function reset_page_and_go(url) {
|
|
window.location = $.param.querystring(window.location.href, 'page=1&' + url);
|
|
}
|
|
|
|
$('select[name=products-sort]').on('change', function () {
|
|
reset_page_and_go('sort=' + $(this).val());
|
|
});
|
|
$('select[name=show-count]').on('change', function () {
|
|
reset_page_and_go('paginate_by=' + $(this).val());
|
|
});
|
|
|
|
var category_sort = $.deparam.querystring().sort;
|
|
if (category_sort) {
|
|
$("select[name=products-sort] option[value=" + category_sort + "]").prop("selected", "selected");
|
|
}
|
|
var paginate_by = $.deparam.querystring().paginate_by;
|
|
if (paginate_by) {
|
|
$("select[name=show-count] option[value=" + paginate_by + "]").prop("selected", "selected");
|
|
}
|
|
$('.paginate a').on('click', function () {
|
|
window.location = $.param.querystring(window.location.href, $(this).attr('href').replace('?', ''));
|
|
return false;
|
|
});
|
|
|
|
$('.attr-filter').each(function () {
|
|
var check_block = $(this);
|
|
var checkboxes = [];
|
|
|
|
$(this).find('input:checkbox').each(function () {
|
|
var current_checkbox = $(this);
|
|
checkboxes.push(current_checkbox);
|
|
current_checkbox.change(function () {
|
|
var retstring = '';
|
|
$.each(checkboxes, function () {
|
|
if ($(this).prop('name') != current_checkbox.prop('name')) {
|
|
var checkval = 'false';
|
|
if ($(this).prop('checked')) {
|
|
checkval = $(this).val();
|
|
}
|
|
retstring += '&' + $(this).prop('name') + '=' + checkval;
|
|
}
|
|
});
|
|
|
|
var current_val = 'false';
|
|
|
|
if (current_checkbox.prop('checked')) {
|
|
current_val = current_checkbox.val()
|
|
}
|
|
retstring += '&' + current_checkbox.prop('name') + '=' + current_val
|
|
reset_page_and_go(retstring);
|
|
});
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
$('.product-min-thumbnails a').each(function () {
|
|
var link = $(this);
|
|
link.on('click', function () {
|
|
$('.product-big-thumbnail img').prop('src', link.prop('href'));
|
|
$('#product-big-img').attr('data-zoom-image', link.attr("data-big-url"));
|
|
$('.zoomContainer').remove();
|
|
$('#product-big-img').removeData('elevateZoom');
|
|
$('#product-big-img').removeData('zoomImage');
|
|
$('#product-big-img').elevateZoom({
|
|
zoomType: "inner",
|
|
cursor: "crosshair",
|
|
lensFadeIn: 500,
|
|
lensFadeOut: 500,
|
|
easing: true
|
|
});
|
|
|
|
|
|
// $('.product-big-thumbnail-container').trigger('zoom.destroy');
|
|
// $('.product-big-thumbnail-container').zoom({url: link.attr("data-big-url")});
|
|
//$('a#product-big-image-url').prop('href', link.attr('data-big-url'))
|
|
return false;
|
|
})
|
|
});
|
|
$('#product-big-img').elevateZoom({
|
|
zoomType: "inner",
|
|
cursor: "crosshair",
|
|
lensFadeIn: 500,
|
|
lensFadeOut: 500,
|
|
easing: true
|
|
});
|
|
//$('.product-big-thumbnail-container').zoom({url: $('#product-big-image-url').prop("href")});
|
|
|
|
|
|
function create_cart_add_link(product_pk, count) {
|
|
return $.param.querystring('/store/cart/add/', 'pk=' + product_pk + '&count=' + count + '&next=' + window.location.pathname);
|
|
}
|
|
|
|
function selectVariation(value, index) {
|
|
var price = $('.product-variations-selecter option[value=' + value + ']').attr('data-price');
|
|
var in_stock = $('.product-variations-selecter option[value=' + value + ']').attr('data-count');
|
|
$('.product-detail-price-span').html(price);
|
|
if (in_stock > 0) {
|
|
$(".product-count-selecter").dropdown('destroy');
|
|
$('.product-in-stock').show();
|
|
$('.product-not-in-stock').hide();
|
|
$('.product-count-selecter').html('');
|
|
for (i = 0; i < in_stock; i++) {
|
|
var option = $('<option/>');
|
|
option.attr({'value': i + 1}).text((i + 1) + ' шт.');
|
|
$('.product-count-selecter').append(option);
|
|
}
|
|
//$(".product-count-selecter")
|
|
$(".product-count-selecter").dropdown();
|
|
$(".product-count-selecter").on("change", function () {
|
|
selectCount($(this).val(), $(this).index());
|
|
});
|
|
selectCount(1, index);
|
|
$('#product-add-to-cart-link').prop('href',
|
|
create_cart_add_link($('.product-variations-selecter').val(),
|
|
$('.product-count-selecter').val()));
|
|
} else {
|
|
$('.product-count-selecter').dropdown('destroy');
|
|
$('.product-in-stock').hide();
|
|
$('.product-not-in-stock').show();
|
|
}
|
|
|
|
}
|
|
|
|
$(".product-variations-selecter").dropdown();
|
|
$(".product-variations-selecter").on("change", function () {
|
|
selectVariation($(this).val(), $(this).index());
|
|
});
|
|
|
|
function selectCount(value, index) {
|
|
var price = parseInt($('.product-detail-price-span').html());
|
|
$('.itogo-span').html(price * value);
|
|
$('#product-add-to-cart-link').prop('href',
|
|
create_cart_add_link($('.product-variations-selecter').val(),
|
|
$('.product-count-selecter').val()));
|
|
}
|
|
|
|
$(".product-count-selecter").dropdown();
|
|
$(".product-count-selecter").on("change", function () {
|
|
selectCount($(this).val(), $(this).index());
|
|
});
|
|
|
|
|
|
if ($('.product-count-selecter option').size() < 1) {
|
|
$('.product-in-stock').hide();
|
|
$('.product-not-in-stock').show();
|
|
|
|
} else {
|
|
$(".product-count-selecter").dropdown();
|
|
}
|
|
|
|
$('ul.messages li').each(function () {
|
|
var li = $(this);
|
|
var messageType = li.attr('data-type');
|
|
swal({
|
|
html: true,
|
|
type: messageType,
|
|
title: "OK!",
|
|
text: li.html()
|
|
|
|
});
|
|
});
|
|
|
|
function selectCity() {
|
|
var city = $('#id_city').val();
|
|
var deliv = $('#id_deliv_type').val();
|
|
var cart_itogo = $('#cart-itogo');
|
|
var order_itogo_delivery = $('#order-itogo-delivery');
|
|
var order_itogo = $('#order-itogo-amount');
|
|
var order_itogo_up = $('#order-itogo-amount-up');
|
|
var order_itogo_delivery_up = $('#order-itogo-delivery-up');
|
|
|
|
if (city && deliv) {
|
|
$.ajax({
|
|
method: "GET",
|
|
url: "/get_order_amount/",
|
|
data: {
|
|
city: city,
|
|
deliv: deliv,
|
|
|
|
}
|
|
})
|
|
.done(function (msg) {
|
|
order_itogo.html(
|
|
parseFloat(msg.AmountPlusFSAmount) + parseFloat(cart_itogo.html())
|
|
);
|
|
order_itogo_up.html(
|
|
parseFloat(msg.AmountPlusFSAmount) + parseFloat(cart_itogo.html())
|
|
);
|
|
order_itogo_delivery.html(
|
|
parseFloat(msg.AmountPlusFSAmount)
|
|
);
|
|
//cart_itogo.html(
|
|
// parseFloat(msg.AmountPlusFSAmount) + parseFloat(cart_itogo.html())
|
|
//);
|
|
order_itogo_delivery_up.html(
|
|
parseFloat(msg.AmountPlusFSAmount)
|
|
);
|
|
});
|
|
|
|
} else {
|
|
order_itogo.html(cart_itogo);
|
|
order_itogo_up.html(cart_itogo);
|
|
order_itogo_delivery.html(0);
|
|
order_itogo_delivery_up.html(0);
|
|
}
|
|
}
|
|
|
|
function selectKazpostCity() {
|
|
var city = $('#id_kazpost_city').val();
|
|
var cart_itogo = $('#cart-itogo');
|
|
var order_itogo_delivery = $('#order-itogo-delivery');
|
|
var order_itogo = $('#order-itogo-amount');
|
|
var order_itogo_up = $('#order-itogo-amount-up');
|
|
var order_itogo_delivery_up = $('#order-itogo-delivery-up');
|
|
|
|
if (city) {
|
|
$.ajax({
|
|
method: "GET",
|
|
url: "/get_order_kazpost_amount/",
|
|
data: {
|
|
city: city,
|
|
|
|
}
|
|
})
|
|
.done(function (msg) {
|
|
order_itogo.html(
|
|
parseFloat(msg.amount) + parseFloat(cart_itogo.html())
|
|
);
|
|
order_itogo_up.html(
|
|
parseFloat(msg.amount) + parseFloat(cart_itogo.html())
|
|
);
|
|
order_itogo_delivery.html(
|
|
parseFloat(msg.amount)
|
|
);
|
|
//cart_itogo.html(
|
|
// parseFloat(msg.AmountPlusFSAmount) + parseFloat(cart_itogo.html())
|
|
//);
|
|
order_itogo_delivery_up.html(
|
|
parseFloat(msg.amount)
|
|
);
|
|
});
|
|
|
|
} else {
|
|
order_itogo.html(cart_itogo);
|
|
order_itogo_up.html(cart_itogo);
|
|
order_itogo_delivery.html(0);
|
|
order_itogo_delivery_up.html(0);
|
|
}
|
|
}
|
|
|
|
|
|
$('#id_kazpost_city').select2({
|
|
placeholder: "Выберите почтовое отделение",
|
|
allowClear: false
|
|
}).on('change', function () {
|
|
selectKazpostCity();
|
|
});
|
|
|
|
|
|
$('#order-call-link, #order-call-link2').magnificPopup({
|
|
type: 'inline',
|
|
preloader: false,
|
|
});
|
|
|
|
$('.order-order-link').magnificPopup({
|
|
type: 'inline',
|
|
preloader: false,
|
|
callbacks: {
|
|
open: function () {
|
|
$('#order-form #id_item').val($(this)[0].currItem.el[0].attributes['data-itemid'].value);
|
|
}
|
|
}
|
|
});
|
|
|
|
function fillHTMLServicesDPD(services, div) {
|
|
|
|
div.empty();
|
|
|
|
for (var i = 0; i < services.length; i++) {
|
|
|
|
var service = services[i];
|
|
|
|
$('<tr/>', {
|
|
'class':'clickable-row',
|
|
'html':
|
|
'<td><div class="radio"><label><input type="radio" value="'+ service.name +'" id="' +
|
|
service.code + '" name="dpd_service"> '+ service.name +
|
|
'</label></div></td><td align="center">' + service.cost + '</td><td align="center">' +
|
|
service.days + '</td>'
|
|
}).appendTo(div);
|
|
|
|
}
|
|
|
|
$(".clickable-row").click(function() {
|
|
|
|
var input = $(this).find('input'),
|
|
cartItogo = $('#cart-itogo'),
|
|
orderItogoDelivery = $('#order-itogo-delivery'),
|
|
orderItogo = $('#order-itogo-amount'),
|
|
orderItogoUp = $('#order-itogo-amount-up'),
|
|
orderItogoDeliveryUp = $('#order-itogo-delivery-up'),
|
|
city = $('#id_dpd_delivery').text(),
|
|
self_delivery = $('input[name=dpd_type_delivery]:checked').val(),
|
|
delivery, result, service;
|
|
|
|
input.prop('checked', true);
|
|
delivery = $(input.children().context.childNodes[1].childNodes[0]).text();
|
|
service = input.val();
|
|
|
|
|
|
// to dour
|
|
if ((self_delivery === 'false') && (input[0].id === 'PCL')) {
|
|
console.log(input);
|
|
if (input.parents()[0].childNodes[1].data === ' DPD CLASSIC Parcel') {
|
|
|
|
if ($(input.parents()[0]).text().indexOf('!') === -1) {
|
|
$(input.parents()[0])[0].innerHTML += '<span style="color:red;"> !</span>';
|
|
}
|
|
|
|
}
|
|
$('#dpd_note').show();
|
|
|
|
delivery = parseFloat(delivery) + 800
|
|
} else {
|
|
$('#dpd_note').hide();
|
|
}
|
|
|
|
orderItogo.html(parseFloat(delivery) + parseFloat(cartItogo.html()));
|
|
orderItogoUp.html(parseFloat(delivery) + parseFloat(cartItogo.html()));
|
|
orderItogoDelivery.html(parseFloat(delivery));
|
|
orderItogoDeliveryUp.html(parseFloat(delivery));
|
|
|
|
// result = {
|
|
// 'city': city,
|
|
// 'self_delivery': self_delivery,
|
|
// 'service': service,
|
|
// 'total': parseFloat(delivery) + parseFloat(cartItogo.html()),
|
|
// 'delivery': parseFloat(delivery)
|
|
// };
|
|
|
|
$('#id_tmp_delivery').val(city);
|
|
$('#id_tmp_cost').val(parseFloat(delivery));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
function selectPickup() {
|
|
var cartItogo = $('#cart-itogo').html();
|
|
|
|
$('#order-itogo-delivery-up').html(0);
|
|
$('#order-itogo-delivery').html(0);
|
|
$('#order-itogo-amount-up').html(parseFloat(cartItogo));
|
|
$('#order-itogo-amount').html(parseFloat(cartItogo));
|
|
}
|
|
|
|
|
|
$( document ).ajaxSend(function( event, jqxhr, settings ) {
|
|
|
|
if (settings.url.indexOf('get_order_dpd_amount') !== -1) {
|
|
$('#ajaxLoading').show();
|
|
|
|
}
|
|
});
|
|
|
|
$( document ).ajaxStop(function() {
|
|
$('#ajaxLoading').hide();
|
|
});
|
|
|
|
function clearAmounts() {
|
|
var cartItogo = $('#cart-itogo').html();
|
|
|
|
$('#order-itogo-delivery-up').html(0);
|
|
$('#order-itogo-delivery').html(0);
|
|
$('#order-itogo-amount-up').html(parseFloat(cartItogo));
|
|
$('#order-itogo-amount').html(parseFloat(cartItogo));
|
|
}
|
|
|
|
function selectDpdCity() {
|
|
var city = $('#id_dpd_delivery').val();
|
|
var city_sent = $('#id_dpd_pickup').val();
|
|
var self_delivery = $('input[name=dpd_type_delivery]:checked').val();
|
|
|
|
// console.log(self_delivery);
|
|
clearAmounts();
|
|
|
|
if (city) {
|
|
$.ajax({
|
|
method: "GET",
|
|
url: "/get_order_dpd_amount/",
|
|
data: {
|
|
delivery: city,
|
|
pickup: city_sent,
|
|
self_delivery: self_delivery
|
|
|
|
}
|
|
}).done(function (obj) {
|
|
|
|
|
|
if (obj.length) {
|
|
$('#dpd_services_no_result').hide();
|
|
fillHTMLServicesDPD(obj, $('#dpd_services_result tbody'));
|
|
$('#dpd_services_result').show();
|
|
|
|
} else {
|
|
$('#dpd_services_no_result').show();
|
|
$('#dpd_services_result').hide();
|
|
}
|
|
});
|
|
} else {
|
|
|
|
var cartItogo = $('#cart-itogo').html();
|
|
|
|
$('#order-itogo-delivery-up').html(0);
|
|
$('#order-itogo-delivery').html(0);
|
|
$('#order-itogo-amount-up').html(parseFloat(cartItogo));
|
|
$('#order-itogo-amount').html(parseFloat(cartItogo));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$("#id_dpd_delivery").select2({
|
|
placeholder: 'Введите название',
|
|
language: "ru",
|
|
minimumInputLength: 2,
|
|
ajax: {
|
|
method: 'GET',
|
|
url: "/get_dpd_cities/",
|
|
dataType: 'json',
|
|
data: function (params) {
|
|
return {
|
|
search: params.term
|
|
};
|
|
},
|
|
processResults: function (data) {
|
|
|
|
return {
|
|
results: data
|
|
};
|
|
},
|
|
cache: true
|
|
}
|
|
});
|
|
|
|
$('#id_dpd_pickup').on('change', function() {
|
|
selectDpdCity();
|
|
$('#dpd_note').hide();
|
|
});
|
|
|
|
|
|
$('#id_dpd_delivery').on('select2:select', function (evt) {
|
|
selectDpdCity();
|
|
$('#dpd_note').hide();
|
|
|
|
});
|
|
|
|
// select type delivery on radiobutton
|
|
$(document).on("change","input[name=dpd_type_delivery]",function(){
|
|
selectDpdCity();
|
|
$('#dpd_note').hide();
|
|
});
|
|
|
|
$('input[name=deliv_service]').change(function () {
|
|
switch ($(this).val()) {
|
|
case 'pickup' :
|
|
selectPickup();
|
|
$('.alemtat_block').hide();
|
|
$('.kazpost_block').hide();
|
|
$('.dpd_block').hide();
|
|
$('#dpd_services_result').hide();
|
|
$('#dpd_services_no_result').hide();
|
|
$('#dpd_note').hide();
|
|
break;
|
|
|
|
case 'kazpost' :
|
|
selectKazpostCity();
|
|
$('.alemtat_block').hide();
|
|
$('.dpd_block').hide();
|
|
$('.kazpost_block').show();
|
|
$('#dpd_services_result').hide();
|
|
$('#dpd_services_no_result').hide();
|
|
$('#dpd_note').hide();
|
|
break;
|
|
|
|
case 'dpd' :
|
|
selectDpdCity();
|
|
$('.alemtat_block').hide();
|
|
$('.kazpost_block').hide();
|
|
$('.dpd_block').show();
|
|
$('#dpd_services_result').hide();
|
|
$('#dpd_services_no_result').hide();
|
|
$('#dpd_note').hide();
|
|
break;
|
|
|
|
case 'alemtat' :
|
|
selectCity();
|
|
$('.alemtat_block').show();
|
|
$('.kazpost_block').hide();
|
|
$('#dpd_services_result').hide();
|
|
$('#dpd_services_no_result').hide();
|
|
$('#dpd_note').hide();
|
|
$('#id_city').select2({
|
|
placeholder: "Выберите город",
|
|
allowClear: false
|
|
}).on('change', function () {
|
|
selectCity();
|
|
});
|
|
|
|
$('#id_deliv_type').select2({
|
|
placeholder: "Выберите способ доставки",
|
|
allowClear: false
|
|
}).on('change', function () {
|
|
selectCity();
|
|
});
|
|
break;
|
|
}
|
|
});
|
|
// not needed
|
|
// selectCity();
|
|
|
|
//selectKazpostCity();
|
|
$('#call-form').on('submit', function () {
|
|
var f_name = $('#call-form #id_name');
|
|
var f_phone = $('#call-form #id_phone');
|
|
var f_time = $('#call-form #id_time');
|
|
var is_full = true;
|
|
|
|
if (!f_name.val()) {
|
|
f_name.parent().parent('.form-group').addClass('has-error');
|
|
is_full = false;
|
|
} else {
|
|
f_name.parent().parent('.form-group').removeClass('has-error');
|
|
}
|
|
if (!f_phone.val()) {
|
|
f_phone.parent().parent('.form-group').addClass('has-error');
|
|
is_full = false;
|
|
} else {
|
|
f_phone.parent().parent('.form-group').removeClass('has-error');
|
|
}
|
|
if (!f_time.val()) {
|
|
f_time.parent().parent('.form-group').addClass('has-error');
|
|
is_full = false;
|
|
} else {
|
|
f_time.parent().parent('.form-group').removeClass('has-error');
|
|
}
|
|
if (is_full) {
|
|
$.ajax({
|
|
type: "POST",
|
|
url: '/order_call/',
|
|
data: {
|
|
name: f_name.val(),
|
|
phone: f_phone.val(),
|
|
time: f_time.val(),
|
|
},
|
|
success: function (data) {
|
|
|
|
$.magnificPopup.close();
|
|
swal("Спасибо!", "Мы приняли вашу заявку! Наш менеджер свяжется с вами в указанное время.", "success")
|
|
|
|
}
|
|
});
|
|
}
|
|
//form-group has-error
|
|
return false;
|
|
});
|
|
|
|
$('#order-form').on('submit', function () {
|
|
var f_name = $('#order-form #id_name');
|
|
var f_phone = $('#order-form #id_phone');
|
|
var f_email = $('#order-form #id_email');
|
|
var f_comment = $('#order-form #id_comment');
|
|
var f_item = $('#order-form #id_item');
|
|
var is_full = true;
|
|
|
|
|
|
if (!f_name.val()) {
|
|
f_name.parent().parent('.form-group').addClass('has-error');
|
|
is_full = false;
|
|
} else {
|
|
f_name.parent().parent('.form-group').removeClass('has-error');
|
|
}
|
|
if (!f_phone.val()) {
|
|
f_phone.parent().parent('.form-group').addClass('has-error');
|
|
is_full = false;
|
|
} else {
|
|
f_phone.parent().parent('.form-group').removeClass('has-error');
|
|
}
|
|
if (is_full) {
|
|
$.ajax({
|
|
type: "POST",
|
|
url: '/order_order/',
|
|
data: {
|
|
name: f_name.val(),
|
|
phone: f_phone.val(),
|
|
email: f_email.val(),
|
|
comment: f_comment.val(),
|
|
item: f_item.val(),
|
|
},
|
|
success: function (data) {
|
|
|
|
$.magnificPopup.close();
|
|
swal("Спасибо!", "Мы приняли вашу заявку! Наш менеджер свяжется с вами в ближайшее время.", "success")
|
|
|
|
}
|
|
});
|
|
}
|
|
//form-group has-error
|
|
return false;
|
|
});
|
|
$('input[name=stars]').each(function () {
|
|
var star = $(this);
|
|
star.parent('label').replaceWith(star);
|
|
});
|
|
$('input[name=stars]').rating();
|
|
$('.star-rating-control').append('<div class="clearfix"></div><br>');
|
|
$('.star').rating();
|
|
|
|
})
|
|
;
|
|
|