<!--СКИДКА ЗА САМОВЫВОЗ-->
<script>
document.addEventListener("DOMContentLoaded", function() {
(function () {
//Название скидки в системе
let dnDelivery = 'Самовывоз 10%';
//Название доставки в корзине
let cartNameDelivery = 'Самовывоз';
//Подпись для подсказки в корзине
let discountHint = 'Скидка за самовывоз 10%';
let discount = 0;
function unactivePickup(){
let newDiscount = [];
for (let key in discount) {
if( discount[key].name != dnDelivery ) newDiscount.push(discount[key]);
};
t_cart__discounts = newDiscount;
updateDicoutns();
};
function activePickup(){
t_cart__discounts = discount;
updateDicoutns();
};
function updateDicoutns(){
tcart__updateTotalProductsinCartObj(),tcart__reDrawTotal(),tcart__saveLocalObj();
};
setTimeout(function () {
discount = t_cart__discounts;
let observer = new MutationObserver(mutationRecords => {
checkDelivery();
});
let elem = document.querySelector('.t706__cartwin-prodamount');
observer.observe(elem, {
childList: true,
subtree: true,
characterDataOldValue: true
});
}, 1000);
let pickupOn = false;
let firstOpen = true;
function checkDelivery(){
let deliveryName = document.querySelector('input.t-radio_delivery:checked');
if(deliveryName==null) {
deliveryName = 0;
}else{
deliveryName = deliveryName.value;
deliveryName = deliveryName.trim()
};
if( deliveryName==cartNameDelivery ){
setTimeout(function() {
let descr = document.querySelector('.t706__cartwin-discounts__description li');
if(descr!=null){
descr.innerText = discountHint;
};
}, 500)
if(!pickupOn){
activePickup();
pickupOn = true;
};
}else{
if(pickupOn || firstOpen){
unactivePickup();
pickupOn = false;
firstOpen = false;
};
};
};
})();
});
</script>
<!--СКИДКА ЗА ON-LINE ОПЛАТУ -->
<script>
document.addEventListener("DOMContentLoaded", function() {
(function () {
//Название скидки в системе
let dnPayment = 'Скидка за оплату 15%';
//Название оплаты в корзине
let cartNamePayment = 'Наличными при получении';
//Подпись для подсказки в корзине
let discountHint = 'Скидка за оплату on-line 15%';
let discountPayment = 0;
function unactivePayment(){
let newDiscountPayment = [];
for (let key in discountPayment) {
if( discountPayment[key].name != dnPayment ) newDiscountPayment.push(discountPayment[key]);
};
t_cart__discounts = newDiscountPayment;
updateDicoutns();
};
function activePayment(){
t_cart__discounts = discountPayment;
updateDicoutns();
};
function updateDicoutns(){
tcart__updateTotalProductsinCartObj(),tcart__reDrawTotal(),tcart__saveLocalObj();
};
setTimeout(function () {
discountPayment = t_cart__discounts;
let observer = new MutationObserver(mutationRecords => {
checkPayment();
});
let elem = document.querySelector('.t706__cartwin-prodamount');
observer.observe(elem, {
childList: true,
subtree: true,
characterDataOldValue: true
});
}, 1000);
let paymentOn = false;
let firstOpen = true;
function checkPayment(){
let paymentName = document.querySelector('input.t-radio_payment:checked').parentElement.innerText;
if(paymentName==null) {
paymentName = 0;
}else{
paymentName = paymentName.trim();
};
if( paymentName==cartNamePayment ){
setTimeout(function() {
let descr = document.querySelector('.t706__cartwin-discounts__description li');
if(descr!=null){
descr.innerText = discountHint;
};
}, 500)
if(!paymentOn){
activePayment();
paymentOn = true;
};
}else{
if(paymentOn || firstOpen){
unactivePayment();
paymentOn = false;
firstOpen = false;
};
};
};
setTimeout(function() {
let paymentInput = document.querySelectorAll('input.t-radio_payment');
paymentInput.forEach(radio => radio.addEventListener('change', () => checkPayment() ));
}, 1000);
})();
});
</script>