|
|
@ -3,292 +3,292 @@ |
|
|
|
(function ($) { |
|
|
|
(function ($) { |
|
|
|
const metaLocale = document.querySelector('meta[property="og:locale"]'); |
|
|
|
const metaLocale = document.querySelector('meta[property="og:locale"]'); |
|
|
|
const localeValue = metaLocale.getAttribute('content'); |
|
|
|
const localeValue = metaLocale.getAttribute('content'); |
|
|
|
function wc_cart_summary_upd(){ |
|
|
|
// function wc_cart_summary_upd(){
|
|
|
|
let total = 0 |
|
|
|
// let total = 0
|
|
|
|
$('.cart_item').each(function(){ |
|
|
|
// $('.cart_item').each(function(){
|
|
|
|
total += Number($(this).data('cost')) |
|
|
|
// total += Number($(this).data('cost'))
|
|
|
|
}) |
|
|
|
// })
|
|
|
|
return total |
|
|
|
// return total
|
|
|
|
} |
|
|
|
// }
|
|
|
|
$('[data-pname]').on('click', function(){ |
|
|
|
// $('[data-pname]').on('click', function(){
|
|
|
|
$('#sub_product_name').val($(this).data('pname')) |
|
|
|
// $('#sub_product_name').val($(this).data('pname'))
|
|
|
|
}) |
|
|
|
// })
|
|
|
|
|
|
|
|
|
|
|
|
$(document).on('submit', '.product-item__form, .detail-block__form', function (e) { |
|
|
|
|
|
|
|
e.preventDefault(); |
|
|
|
|
|
|
|
var $form = $(this) |
|
|
|
|
|
|
|
var product_qty = $form.find('input[name=quantity]').val() || 1 |
|
|
|
|
|
|
|
var product_id = $form.find('input[name=product_id]').val() |
|
|
|
|
|
|
|
var variation_id = $form.find('input[name=variation_id]').val() || 0; |
|
|
|
|
|
|
|
var title = $(this).data('name') |
|
|
|
|
|
|
|
var data = { |
|
|
|
|
|
|
|
action: 'woocommerce_ajax_add_to_cart', |
|
|
|
|
|
|
|
product_id: product_id, |
|
|
|
|
|
|
|
product_sku: '', |
|
|
|
|
|
|
|
quantity: product_qty, |
|
|
|
|
|
|
|
variation_id: variation_id, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
dataLayer.push({ |
|
|
|
|
|
|
|
"ecommerce": { |
|
|
|
|
|
|
|
"currencyCode": "RUB", |
|
|
|
|
|
|
|
"add": { |
|
|
|
|
|
|
|
"products": [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
"id": product_id, |
|
|
|
|
|
|
|
"name": title, |
|
|
|
|
|
|
|
"quantity": product_qty, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(document).on('submit', '.modal__form-sub', function (e) { |
|
|
|
|
|
|
|
e.preventDefault(); |
|
|
|
|
|
|
|
var email = $(this).find('input[name="email"]').val() |
|
|
|
|
|
|
|
var data = $(this).serialize() |
|
|
|
|
|
|
|
$.ajax({ |
|
|
|
|
|
|
|
type: 'post', |
|
|
|
|
|
|
|
url: woocommerce_params.ajax_url, |
|
|
|
|
|
|
|
data: data, |
|
|
|
|
|
|
|
beforeSend: function (response) { |
|
|
|
|
|
|
|
// $thisbutton.removeClass('added').addClass('loading');
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
complete: function (response) { |
|
|
|
|
|
|
|
// $thisbutton.addClass('added').removeClass('loading');
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
success: function (response) { |
|
|
|
|
|
|
|
$('.modal__to-know').removeClass('active') |
|
|
|
|
|
|
|
$('#sub-result-email').html(email) |
|
|
|
|
|
|
|
$('.modal__to-know-submit').addClass('active').css('filter', 'blur(0px)') |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(document).on('submit', '.form--contact', function (e) { |
|
|
|
|
|
|
|
e.preventDefault(); |
|
|
|
|
|
|
|
var form = this; |
|
|
|
|
|
|
|
var data = $(this).serialize() |
|
|
|
|
|
|
|
$.ajax({ |
|
|
|
|
|
|
|
type: 'post', |
|
|
|
|
|
|
|
url: woocommerce_params.ajax_url, |
|
|
|
|
|
|
|
data: data, |
|
|
|
|
|
|
|
beforeSend: function (response) { |
|
|
|
|
|
|
|
// $thisbutton.removeClass('added').addClass('loading');
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
complete: function (response) { |
|
|
|
|
|
|
|
// $thisbutton.addClass('added').removeClass('loading');
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
success: function (response) { |
|
|
|
|
|
|
|
$(form).addClass('submited') |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('body').on('click', '.modal-basket__item-before', function(){ |
|
|
|
// $(document).on('submit', '.product-item__form, .detail-block__form', function (e) {
|
|
|
|
var key = $(this).data('id') |
|
|
|
// e.preventDefault();
|
|
|
|
var p_ID = $(this).data('pr'); |
|
|
|
// var $form = $(this)
|
|
|
|
var var_ID = $(this).data('var'); |
|
|
|
// var product_qty = $form.find('input[name=quantity]').val() || 1
|
|
|
|
var quantity = $(this).closest('.modal-basket__item').find('.counter__input').val() |
|
|
|
// var product_id = $form.find('input[name=product_id]').val()
|
|
|
|
var layout = ` |
|
|
|
// var variation_id = $form.find('input[name=variation_id]').val() || 0;
|
|
|
|
<p class="modal-basket-item__title"> |
|
|
|
// var title = $(this).data('name')
|
|
|
|
Удаление товара из корзины: <span id="${key}_timer" class="timer_counter">5</span>с |
|
|
|
// var data = {
|
|
|
|
</p> |
|
|
|
// action: 'woocommerce_ajax_add_to_cart',
|
|
|
|
|
|
|
|
// product_id: product_id,
|
|
|
|
<button class="modal-basket-item__return" id="${key}_return" data-id="${p_ID}" data-var="${var_ID}" data-quantity="${quantity}"> |
|
|
|
// product_sku: '',
|
|
|
|
Восстановить |
|
|
|
// quantity: product_qty,
|
|
|
|
</button> |
|
|
|
// variation_id: variation_id,
|
|
|
|
` |
|
|
|
// };
|
|
|
|
if(localeValue == 'en_US'){ |
|
|
|
// dataLayer.push({
|
|
|
|
var layout = ` |
|
|
|
// "ecommerce": {
|
|
|
|
<p class="modal-basket-item__title"> |
|
|
|
// "currencyCode": "RUB",
|
|
|
|
Removing product from cart: <span id="${key}_timer" class="timer_counter">5</span>s |
|
|
|
// "add": {
|
|
|
|
</p> |
|
|
|
// "products": [
|
|
|
|
|
|
|
|
// {
|
|
|
|
<button class="modal-basket-item__return" id="${key}_return" data-id="${p_ID}" data-var="${var_ID}" data-quantity="${quantity}"> |
|
|
|
// "id": product_id,
|
|
|
|
Restore |
|
|
|
// "name": title,
|
|
|
|
</button> |
|
|
|
// "quantity": product_qty,
|
|
|
|
` |
|
|
|
// }
|
|
|
|
} |
|
|
|
// ]
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// return false;
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// $(document).on('submit', '.modal__form-sub', function (e) {
|
|
|
|
|
|
|
|
// e.preventDefault();
|
|
|
|
|
|
|
|
// var email = $(this).find('input[name="email"]').val()
|
|
|
|
|
|
|
|
// var data = $(this).serialize()
|
|
|
|
|
|
|
|
// $.ajax({
|
|
|
|
|
|
|
|
// type: 'post',
|
|
|
|
|
|
|
|
// url: woocommerce_params.ajax_url,
|
|
|
|
|
|
|
|
// data: data,
|
|
|
|
|
|
|
|
// beforeSend: function (response) {
|
|
|
|
|
|
|
|
// // $thisbutton.removeClass('added').addClass('loading');
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// complete: function (response) {
|
|
|
|
|
|
|
|
// // $thisbutton.addClass('added').removeClass('loading');
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// success: function (response) {
|
|
|
|
|
|
|
|
// $('.modal__to-know').removeClass('active')
|
|
|
|
|
|
|
|
// $('#sub-result-email').html(email)
|
|
|
|
|
|
|
|
// $('.modal__to-know-submit').addClass('active').css('filter', 'blur(0px)')
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// $(document).on('submit', '.form--contact', function (e) {
|
|
|
|
|
|
|
|
// e.preventDefault();
|
|
|
|
|
|
|
|
// var form = this;
|
|
|
|
|
|
|
|
// var data = $(this).serialize()
|
|
|
|
|
|
|
|
// $.ajax({
|
|
|
|
|
|
|
|
// type: 'post',
|
|
|
|
|
|
|
|
// url: woocommerce_params.ajax_url,
|
|
|
|
|
|
|
|
// data: data,
|
|
|
|
|
|
|
|
// beforeSend: function (response) {
|
|
|
|
|
|
|
|
// // $thisbutton.removeClass('added').addClass('loading');
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// complete: function (response) {
|
|
|
|
|
|
|
|
// // $thisbutton.addClass('added').removeClass('loading');
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// success: function (response) {
|
|
|
|
|
|
|
|
// $(form).addClass('submited')
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// $('body').on('click', '.modal-basket__item-before', function(){
|
|
|
|
|
|
|
|
// var key = $(this).data('id')
|
|
|
|
|
|
|
|
// var p_ID = $(this).data('pr');
|
|
|
|
|
|
|
|
// var var_ID = $(this).data('var');
|
|
|
|
|
|
|
|
// var quantity = $(this).closest('.modal-basket__item').find('.counter__input').val()
|
|
|
|
|
|
|
|
// var layout = `
|
|
|
|
|
|
|
|
// <p class="modal-basket-item__title">
|
|
|
|
|
|
|
|
// Удаление товара из корзины: <span id="${key}_timer" class="timer_counter">5</span>с
|
|
|
|
|
|
|
|
// </p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// <button class="modal-basket-item__return" id="${key}_return" data-id="${p_ID}" data-var="${var_ID}" data-quantity="${quantity}">
|
|
|
|
|
|
|
|
// Восстановить
|
|
|
|
|
|
|
|
// </button>
|
|
|
|
|
|
|
|
// `
|
|
|
|
|
|
|
|
// if(localeValue == 'en_US'){
|
|
|
|
|
|
|
|
// var layout = `
|
|
|
|
|
|
|
|
// <p class="modal-basket-item__title">
|
|
|
|
|
|
|
|
// Removing product from cart: <span id="${key}_timer" class="timer_counter">5</span>s
|
|
|
|
|
|
|
|
// </p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// <button class="modal-basket-item__return" id="${key}_return" data-id="${p_ID}" data-var="${var_ID}" data-quantity="${quantity}">
|
|
|
|
|
|
|
|
// Restore
|
|
|
|
|
|
|
|
// </button>
|
|
|
|
|
|
|
|
// `
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
var old_html = $(this).closest('.modal-basket__item').html() |
|
|
|
// var old_html = $(this).closest('.modal-basket__item').html()
|
|
|
|
$(this).closest('.modal-basket__item').addClass('.modal-basket__item--return').html(layout) |
|
|
|
// $(this).closest('.modal-basket__item').addClass('.modal-basket__item--return').html(layout)
|
|
|
|
var title = $(this).closest('.cart_item').find('.modal-basket-item__title').html() |
|
|
|
// var title = $(this).closest('.cart_item').find('.modal-basket-item__title').html()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var timerVal = 5; |
|
|
|
// var timerVal = 5;
|
|
|
|
|
|
|
|
|
|
|
|
var interval = setInterval(function(){ |
|
|
|
// var interval = setInterval(function(){
|
|
|
|
timerVal -= 1; |
|
|
|
// timerVal -= 1;
|
|
|
|
if (timerVal > 0){ |
|
|
|
// if (timerVal > 0){
|
|
|
|
$(`#${key}_timer`).html(timerVal) |
|
|
|
// $(`#${key}_timer`).html(timerVal)
|
|
|
|
} |
|
|
|
// }
|
|
|
|
else{ |
|
|
|
// else{
|
|
|
|
|
|
|
|
|
|
|
|
dataLayer.push({ |
|
|
|
// dataLayer.push({
|
|
|
|
"ecommerce": { |
|
|
|
// "ecommerce": {
|
|
|
|
"currencyCode": "RUB", |
|
|
|
// "currencyCode": "RUB",
|
|
|
|
"remove": { |
|
|
|
// "remove": {
|
|
|
|
"products": [ |
|
|
|
// "products": [
|
|
|
|
{ |
|
|
|
// {
|
|
|
|
"id": p_ID, |
|
|
|
// "id": p_ID,
|
|
|
|
"name": title, |
|
|
|
// "name": title,
|
|
|
|
"quantity": quantity, |
|
|
|
// "quantity": quantity,
|
|
|
|
} |
|
|
|
// }
|
|
|
|
] |
|
|
|
// ]
|
|
|
|
} |
|
|
|
// }
|
|
|
|
} |
|
|
|
// }
|
|
|
|
}); |
|
|
|
// });
|
|
|
|
var input = 0; |
|
|
|
// var input = 0;
|
|
|
|
var productID = key; |
|
|
|
// var productID = key;
|
|
|
|
|
|
|
|
|
|
|
|
var data = { |
|
|
|
// var data = {
|
|
|
|
action: 'get_cartprice', |
|
|
|
// action: 'get_cartprice',
|
|
|
|
quantity: input, |
|
|
|
// quantity: input,
|
|
|
|
product: productID |
|
|
|
// product: productID
|
|
|
|
}; |
|
|
|
// };
|
|
|
|
$.ajax({ |
|
|
|
// $.ajax({
|
|
|
|
type: 'post', |
|
|
|
// type: 'post',
|
|
|
|
url: '/wp-admin/admin-ajax.php', |
|
|
|
// url: '/wp-admin/admin-ajax.php',
|
|
|
|
data: data, |
|
|
|
// data: data,
|
|
|
|
beforeSend: function (response) { |
|
|
|
// beforeSend: function (response) {
|
|
|
|
// $thisbutton.removeClass('added').addClass('loading');
|
|
|
|
// // $thisbutton.removeClass('added').addClass('loading');
|
|
|
|
}, |
|
|
|
// },
|
|
|
|
complete: function (response) { |
|
|
|
// complete: function (response) {
|
|
|
|
// $thisbutton.addClass('added').removeClass('loading');
|
|
|
|
// // $thisbutton.addClass('added').removeClass('loading');
|
|
|
|
}, |
|
|
|
// },
|
|
|
|
success: function (response) { |
|
|
|
// success: function (response) {
|
|
|
|
|
|
|
|
|
|
|
|
if(response['cart_count'] > 0){ |
|
|
|
// if(response['cart_count'] > 0){
|
|
|
|
$('.mini-profile__button--counter').removeClass('disabled').html(response['cart_count']) |
|
|
|
// $('.mini-profile__button--counter').removeClass('disabled').html(response['cart_count'])
|
|
|
|
} |
|
|
|
// }
|
|
|
|
else{ |
|
|
|
// else{
|
|
|
|
$('.mini-profile__button--counter').addClass('disabled').html(response['cart_count']) |
|
|
|
// $('.mini-profile__button--counter').addClass('disabled').html(response['cart_count'])
|
|
|
|
} |
|
|
|
// }
|
|
|
|
}, |
|
|
|
// },
|
|
|
|
}); |
|
|
|
// });
|
|
|
|
$(`#${key}_timer`).closest('.modal-basket__item').remove() |
|
|
|
// $(`#${key}_timer`).closest('.modal-basket__item').remove()
|
|
|
|
if (Number(wc_cart_summary_upd()) > 0){ |
|
|
|
// if (Number(wc_cart_summary_upd()) > 0){
|
|
|
|
$('#cart_total').html(wc_cart_summary_upd()) |
|
|
|
// $('#cart_total').html(wc_cart_summary_upd())
|
|
|
|
} |
|
|
|
// }
|
|
|
|
else{ |
|
|
|
// else{
|
|
|
|
var tmpl = `<div class="modal__header --nb">
|
|
|
|
// var tmpl = `<div class="modal__header --nb">
|
|
|
|
<p class="modal__title">Корзина</p> |
|
|
|
// <p class="modal__title">Корзина</p>
|
|
|
|
<p class="modal__text">Ваша корзина пуста</p> |
|
|
|
// <p class="modal__text">Ваша корзина пуста</p>
|
|
|
|
</div> |
|
|
|
// </div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="modal__footer"> |
|
|
|
// <div class="modal__footer">
|
|
|
|
<div class="modal__block-button"> |
|
|
|
// <div class="modal__block-button">
|
|
|
|
<div class="modal__button"> |
|
|
|
// <div class="modal__button">
|
|
|
|
<a href="/shop/" class="button button--100-perc button--link button--white"> |
|
|
|
// <a href="/shop/" class="button button--100-perc button--link button--white">
|
|
|
|
Продолжить покупки |
|
|
|
// Продолжить покупки
|
|
|
|
</a> |
|
|
|
// </a>
|
|
|
|
</div> |
|
|
|
// </div>
|
|
|
|
</div> |
|
|
|
// </div>
|
|
|
|
</div>` |
|
|
|
// </div>`
|
|
|
|
|
|
|
|
|
|
|
|
if(localeValue == 'en_US'){ |
|
|
|
// if(localeValue == 'en_US'){
|
|
|
|
var tmpl = `<div class="modal__header --nb">
|
|
|
|
// var tmpl = `<div class="modal__header --nb">
|
|
|
|
<p class="modal__title">Cart</p> |
|
|
|
// <p class="modal__title">Cart</p>
|
|
|
|
<p class="modal__text">Your cart is empty</p> |
|
|
|
// <p class="modal__text">Your cart is empty</p>
|
|
|
|
</div> |
|
|
|
// </div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="modal__footer"> |
|
|
|
// <div class="modal__footer">
|
|
|
|
<div class="modal__block-button"> |
|
|
|
// <div class="modal__block-button">
|
|
|
|
<div class="modal__button"> |
|
|
|
// <div class="modal__button">
|
|
|
|
<a href="/en/shop-3/" class="button button--100-perc button--link button--white"> |
|
|
|
// <a href="/en/shop-3/" class="button button--100-perc button--link button--white">
|
|
|
|
Return to catalog |
|
|
|
// Return to catalog
|
|
|
|
</a> |
|
|
|
// </a>
|
|
|
|
</div> |
|
|
|
// </div>
|
|
|
|
</div> |
|
|
|
// </div>
|
|
|
|
</div>` |
|
|
|
// </div>`
|
|
|
|
} |
|
|
|
// }
|
|
|
|
$('.modal__basket').html(tmpl) |
|
|
|
// $('.modal__basket').html(tmpl)
|
|
|
|
} |
|
|
|
// }
|
|
|
|
clearInterval(interval); |
|
|
|
// clearInterval(interval);
|
|
|
|
} |
|
|
|
// }
|
|
|
|
}, 1000) |
|
|
|
// }, 1000)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(`#${key}_return`).one('click', function(){ |
|
|
|
// $(`#${key}_return`).one('click', function(){
|
|
|
|
$(this).closest('.modal-basket__item').removeClass('.modal-basket__item--return').html(old_html) |
|
|
|
// $(this).closest('.modal-basket__item').removeClass('.modal-basket__item--return').html(old_html)
|
|
|
|
clearInterval(interval); |
|
|
|
// clearInterval(interval);
|
|
|
|
}) |
|
|
|
// })
|
|
|
|
}) |
|
|
|
// })
|
|
|
|
|
|
|
|
|
|
|
|
$('body').on('click', '.state__button', function(){ |
|
|
|
// $('body').on('click', '.state__button', function(){
|
|
|
|
var s = $(this).closest('.select') |
|
|
|
// var s = $(this).closest('.select')
|
|
|
|
var id = $(this).data('id') |
|
|
|
// var id = $(this).data('id')
|
|
|
|
var bc = $(this).data('bc') |
|
|
|
// var bc = $(this).data('bc')
|
|
|
|
|
|
|
|
|
|
|
|
var form = $(this).closest('.product-item__form') |
|
|
|
// var form = $(this).closest('.product-item__form')
|
|
|
|
|
|
|
|
|
|
|
|
$(form).find('input[name="variation_id"]').val(id) |
|
|
|
// $(form).find('input[name="variation_id"]').val(id)
|
|
|
|
$(form).find('.counter__input').data('maxcount', $(this).data('stock')).attr('data-maxcount', $(this).data('stock')) |
|
|
|
// $(form).find('.counter__input').data('maxcount', $(this).data('stock')).attr('data-maxcount', $(this).data('stock'))
|
|
|
|
if (Number($(form).find('.counter__input').val()) > Number($(form).find('.counter__input').data('maxcount'))){ |
|
|
|
// if (Number($(form).find('.counter__input').val()) > Number($(form).find('.counter__input').data('maxcount'))){
|
|
|
|
$(form).find('.counter__input').val($(form).find('.counter__input').data('maxcount')) |
|
|
|
// $(form).find('.counter__input').val($(form).find('.counter__input').data('maxcount'))
|
|
|
|
} |
|
|
|
// }
|
|
|
|
var input = $(form).find('.counter__input').val() |
|
|
|
// var input = $(form).find('.counter__input').val()
|
|
|
|
$(form).find('.product-item-overlay__price').data('basecost', bc).html(Number(bc) * Number(input)) |
|
|
|
// $(form).find('.product-item-overlay__price').data('basecost', bc).html(Number(bc) * Number(input))
|
|
|
|
}) |
|
|
|
// })
|
|
|
|
|
|
|
|
|
|
|
|
$('body').on('click', '.btn-load-ajax', function(){ |
|
|
|
// $('body').on('click', '.btn-load-ajax', function(){
|
|
|
|
var page = Number($(this).data('page')) + 1 |
|
|
|
// var page = Number($(this).data('page')) + 1
|
|
|
|
var maxpage = Number($(this).data('maxpage')) |
|
|
|
// var maxpage = Number($(this).data('maxpage'))
|
|
|
|
var data = { |
|
|
|
// var data = {
|
|
|
|
ajax_load: 'ajax',
|
|
|
|
// ajax_load: 'ajax',
|
|
|
|
}; |
|
|
|
// };
|
|
|
|
var btn = this |
|
|
|
// var btn = this
|
|
|
|
var baseUrl = jQuery(location).attr('origin') + jQuery(location).attr('pathname') |
|
|
|
// var baseUrl = jQuery(location).attr('origin') + jQuery(location).attr('pathname')
|
|
|
|
baseUrl += 'page/' + page + '/' |
|
|
|
// baseUrl += 'page/' + page + '/'
|
|
|
|
var searchUrl = baseUrl |
|
|
|
// var searchUrl = baseUrl
|
|
|
|
if (jQuery(location).attr('search')){ |
|
|
|
// if (jQuery(location).attr('search')){
|
|
|
|
searchUrl += jQuery(location).attr('search') + '&ajax_search=ajax' |
|
|
|
// searchUrl += jQuery(location).attr('search') + '&ajax_search=ajax'
|
|
|
|
} |
|
|
|
// }
|
|
|
|
else{ |
|
|
|
// else{
|
|
|
|
searchUrl += '?ajax_search=ajax' |
|
|
|
// searchUrl += '?ajax_search=ajax'
|
|
|
|
} |
|
|
|
// }
|
|
|
|
$.ajax({ |
|
|
|
// $.ajax({
|
|
|
|
type: 'get', |
|
|
|
// type: 'get',
|
|
|
|
url: searchUrl, |
|
|
|
// url: searchUrl,
|
|
|
|
data: data, |
|
|
|
// data: data,
|
|
|
|
beforeSend: function (response) { |
|
|
|
// beforeSend: function (response) {
|
|
|
|
$(btn).attr('disabled', true) |
|
|
|
// $(btn).attr('disabled', true)
|
|
|
|
$(btn).attr('data-page', page) |
|
|
|
// $(btn).attr('data-page', page)
|
|
|
|
$(btn).data('page', page) |
|
|
|
// $(btn).data('page', page)
|
|
|
|
}, |
|
|
|
// },
|
|
|
|
complete: function (response) { |
|
|
|
// complete: function (response) {
|
|
|
|
if (page >= maxpage){ |
|
|
|
// if (page >= maxpage){
|
|
|
|
$(btn).remove() |
|
|
|
// $(btn).remove()
|
|
|
|
} |
|
|
|
// }
|
|
|
|
else{ |
|
|
|
// else{
|
|
|
|
$(btn).attr('disabled', false) |
|
|
|
// $(btn).attr('disabled', false)
|
|
|
|
} |
|
|
|
// }
|
|
|
|
}, |
|
|
|
// },
|
|
|
|
success: function (response) { |
|
|
|
// success: function (response) {
|
|
|
|
$('.products').append(response) |
|
|
|
// $('.products').append(response)
|
|
|
|
initCounters() |
|
|
|
// initCounters()
|
|
|
|
initOverlay() |
|
|
|
// initOverlay()
|
|
|
|
initSelect() |
|
|
|
// initSelect()
|
|
|
|
modalOpen('.open-to-know', '.modal__to-know'); |
|
|
|
// modalOpen('.open-to-know', '.modal__to-know');
|
|
|
|
|
|
|
|
|
|
|
|
/// РЕШЕНИЕ ДЛЯ СТЕНДА AJAX ДЛЯ ПОДГРУЗКИ AJAX
|
|
|
|
// /// РЕШЕНИЕ ДЛЯ СТЕНДА AJAX ДЛЯ ПОДГРУЗКИ AJAX
|
|
|
|
document.querySelectorAll('img').forEach(img => {
|
|
|
|
// document.querySelectorAll('img').forEach(img => {
|
|
|
|
var str = img.attributes['src'].value.replace('https://cosmopet.good-production.xyz/', 'https://cosmopet.shop/') |
|
|
|
// var str = img.attributes['src'].value.replace('https://cosmopet.good-production.xyz/', 'https://cosmopet.shop/')
|
|
|
|
checkImage(str, function(){ img.attributes['src'].value = str }); |
|
|
|
// checkImage(str, function(){ img.attributes['src'].value = str });
|
|
|
|
if (img.attributes['srcset']){ |
|
|
|
// if (img.attributes['srcset']){
|
|
|
|
img.attributes['srcset'].value = img.attributes['srcset'].value.replace('cosmopet.good-production.xyz', '<?=$main_host?>') |
|
|
|
// img.attributes['srcset'].value = img.attributes['srcset'].value.replace('cosmopet.good-production.xyz', '<?=$main_host?>')
|
|
|
|
} |
|
|
|
// }
|
|
|
|
}) |
|
|
|
// })
|
|
|
|
//
|
|
|
|
// //
|
|
|
|
}, |
|
|
|
// },
|
|
|
|
}); |
|
|
|
// });
|
|
|
|
}) |
|
|
|
// })
|
|
|
|
|
|
|
|
|
|
|
|
// $('body').on('click', '.singular-w-btn', function(){
|
|
|
|
// $('body').on('click', '.singular-w-btn', function(){
|
|
|
|
// var wg = $(this).data('wg')
|
|
|
|
// var wg = $(this).data('wg')
|
|
|
@ -307,61 +307,62 @@ |
|
|
|
|
|
|
|
|
|
|
|
// })
|
|
|
|
// })
|
|
|
|
// асинхронный запрос при отправке формы
|
|
|
|
// асинхронный запрос при отправке формы
|
|
|
|
$( '#ajaxform' ).on( 'submit',function( event ) { |
|
|
|
// $( '#ajaxform' ).on( 'submit',function( event ) {
|
|
|
|
event.preventDefault(); |
|
|
|
// event.preventDefault();
|
|
|
|
|
|
|
|
|
|
|
|
const form = $(this); |
|
|
|
// const form = $(this);
|
|
|
|
|
|
|
|
|
|
|
|
$.ajax( { |
|
|
|
// $.ajax( {
|
|
|
|
type : 'POST', |
|
|
|
// type : 'POST',
|
|
|
|
url : woocommerce_params.ajax_url, |
|
|
|
// url : woocommerce_params.ajax_url,
|
|
|
|
data : form.serialize(), |
|
|
|
// data : form.serialize(),
|
|
|
|
beforeSend : function( xhr ) { |
|
|
|
// beforeSend : function( xhr ) {
|
|
|
|
$('.products').addClass('loading') |
|
|
|
// $('.products').addClass('loading')
|
|
|
|
form.find('.button-submit').addClass('loading').attr('disabled', true) |
|
|
|
// form.find('.button-submit').addClass('loading').attr('disabled', true)
|
|
|
|
}, |
|
|
|
// },
|
|
|
|
success : function( data ) { |
|
|
|
// success : function( data ) {
|
|
|
|
$( '.products' ).html( data.products ); |
|
|
|
// $( '.products' ).html( data.products );
|
|
|
|
$('.product__tag').html(data.tags); |
|
|
|
// $('.product__tag').html(data.tags);
|
|
|
|
$( '.btn-load-ajax' ).remove() |
|
|
|
// $( '.btn-load-ajax' ).remove()
|
|
|
|
form.find('.button-submit').removeClass('loading').attr('disabled', false) |
|
|
|
// form.find('.button-submit').removeClass('loading').attr('disabled', false)
|
|
|
|
form.find('.modal__close').click() |
|
|
|
// form.find('.modal__close').click()
|
|
|
|
$('.products').removeClass('loading') |
|
|
|
// $('.products').removeClass('loading')
|
|
|
|
if (data.err){ |
|
|
|
// if (data.err){
|
|
|
|
$('.product__error-button').show() |
|
|
|
// $('.product__error-button').show()
|
|
|
|
} |
|
|
|
// }
|
|
|
|
else{ |
|
|
|
// else{
|
|
|
|
$('.product__error-button').hide() |
|
|
|
// $('.product__error-button').hide()
|
|
|
|
} |
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
initCounters() |
|
|
|
// initCounters()
|
|
|
|
initOverlay() |
|
|
|
// initOverlay()
|
|
|
|
initSelect() |
|
|
|
// initSelect()
|
|
|
|
modalOpen('.open-to-know', '.modal__to-know'); |
|
|
|
// modalOpen('.open-to-know', '.modal__to-know');
|
|
|
|
|
|
|
|
|
|
|
|
document.querySelectorAll('img').forEach(img => {
|
|
|
|
// document.querySelectorAll('img').forEach(img => {
|
|
|
|
var str = img.attributes['src'].value.replace('https://cosmopet.good-production.xyz/', 'https://cosmopet.shop/') |
|
|
|
// var str = img.attributes['src'].value.replace('https://cosmopet.good-production.xyz/', 'https://cosmopet.shop/')
|
|
|
|
checkImage(str, function(){ img.attributes['src'].value = str }); |
|
|
|
// checkImage(str, function(){ img.attributes['src'].value = str });
|
|
|
|
if (img.attributes['srcset']){ |
|
|
|
// if (img.attributes['srcset']){
|
|
|
|
img.attributes['srcset'].value = img.attributes['srcset'].value.replace('cosmopet.good-production.xyz', '<?=$main_host?>') |
|
|
|
// img.attributes['srcset'].value = img.attributes['srcset'].value.replace('cosmopet.good-production.xyz', '<?=$main_host?>')
|
|
|
|
} |
|
|
|
// }
|
|
|
|
}) |
|
|
|
// })
|
|
|
|
} |
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
} ); |
|
|
|
// } );
|
|
|
|
|
|
|
|
|
|
|
|
} ); |
|
|
|
// } );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('body').on('click', '.product-tag__item', function(){ |
|
|
|
// $('body').on('click', '.product-tag__item', function(){
|
|
|
|
$('#tax_' + $(this).data('tag')).find('input').prop('checked', false) |
|
|
|
// $('#tax_' + $(this).data('tag')).find('input').prop('checked', false)
|
|
|
|
$('#tax_' + $(this).data('tag')).removeClass('active'); |
|
|
|
// $('#tax_' + $(this).data('tag')).removeClass('active');
|
|
|
|
$(this).remove() |
|
|
|
// $(this).remove()
|
|
|
|
$('#ajaxform').submit() |
|
|
|
// $('#ajaxform').submit()
|
|
|
|
}) |
|
|
|
// })
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Login
|
|
|
|
// Login
|
|
|
|
|
|
|
|
|
|
|
|
$('.login_popup').on('click', function(e){ |
|
|
|
$('.login_popup').on('click', function(e){ |
|
|
|
e.preventDefault(); |
|
|
|
e.preventDefault(); |
|
|
|
$('.login_modal').addClass('active'); |
|
|
|
$('.login_modal').addClass('active'); |
|
|
|