<script>
$(document).ready(function(){
//Контроль скидки по итоговой сумме или кол-ву товара
let discountTrigger = "price"; // price - цена, quantity - кол-во
// 5% - скидка в процентах, 3000 - вычесть число от суммы
let codeList = [// триггер, скидка, имя помокода,
[ 3000, '5%' , 'D5' ],
[ 6000, '10%' , 'D10' ],
[ 10000, '15%' , 'D15' ],
[ 15000, '20%' , 'D20' ],
[ 20000, '3000' , 'D3K' ],
[ 30000, '6000' , 'D6K' ]
];
let triggerValue=0;
let currentDiscount = [];
let upswing=false;
let saveinputPC='';
let cartID = $('div[data-record-type="706"]').attr('id').replace(/[^0-9]/g, '');
let pcLid = $('.t-input-group_pc').attr('data-input-lid');
setTimeout(function(){ saveinputPC = $('.t-inputpromocode__wrapper').html()}, 1000);
function getDiscountInfo(trval){
let prevLine = 0;let minTotal = 0;
for(let i=0;i<codeList.length;i++){
if(trval >= codeList[i][0] && codeList[i][0] > prevLine ){prevLine = codeList[i][0];
for (let j=0;j<2;j++){currentDiscount[j]=codeList[i][j+1]};upswing=true;
}else if(trval < codeList[i][0]) minTotal++;
};
if (minTotal == codeList.length && upswing) {
currentDiscount = [];clearDiscount();upswing=false;
if(pcLid != undefined ){
$('.t-input-group_pc').show();
$('.t-inputpromocode__wrapper').html(saveinputPC);
t_input_promocode_init(cartID,pcLid);
};
};
if(currentDiscount.length){
$('.t-input-group_pc').hide();
window.tcart.promocode = {};
let totalWrap = $('.t706__cartwin-totalamount-wrap');
if(currentDiscount[0].indexOf('%') > 0 ){
window.tcart.promocode.discountpercent = (+currentDiscount[0].replace(/[^0-9.]/g, '')).toFixed(2);
clearTotalWrapClass();totalWrap.addClass('prcode_act_percent');
}else{
window.tcart.promocode.discountsum = currentDiscount[0]
clearTotalWrapClass();totalWrap.addClass('prcode_act_summ');
};
window.tcart.promocode.message = "OK";
window.tcart.promocode.promocode = currentDiscount[1];
tcart__updateTotalProductsinCartObj();
};
};
function clearTotalWrapClass(){ $('.t706__cartwin-totalamount-wrap').removeClass('prcode_act_percent prcode_act_summ')};
function clearDiscount(){
if ( window.tcart.hasOwnProperty("promocode") ){
delete window.tcart.promocode; tcart__updateTotalProductsinCartObj();clearTotalWrapClass();
};
};
$(".t706__cartwin-prodamount").bind( 'DOMSubtreeModified',function() {
if (discountTrigger=="price"){triggerValue = window.tcart.prodamount;}else{triggerValue = window.tcart.total}; getDiscountInfo(triggerValue);
});
});
</script>
<style>
.t706__cartwin-totalamount-wrap {
display: block !important;
order: -1;
margin-bottom: 25px;
}
span.t706__cartwin-totalamount-label:before {
content: "Сумма к оплате:";
position: absolute;
right: 10px;
width: 300%;
color: #000;
}
span.t706__cartwin-totalamount-label, .prcode_act_percent .t706__cartwin-totalamount-info span:nth-of-type(3) {
position: relative;
color: transparent;
}
.prcode_act_percent .t706__cartwin-totalamount-info span:nth-of-type(3):before {
content: "Процент скидки:";
position: absolute;
right: 1px;
width: 300%;
color: #000;
}
.prcode_act_summ .t706__cartwin-totalamount-info span:nth-of-type(3),
.prcode_act_summ .t706__cartwin-totalamount-info span:nth-of-type(4),
.prcode_act_summ .t706__cartwin-totalamount-info span:nth-of-type(4)+br {
display: none;
}
.t706 .t-form__inputsbox {
display: flex;
flex-direction: column;
}
.t706__cartwin-bottom {display: none}
.t706__orderform { margin-top: -5px}
</style>
<script>
$(document).ready(function(){
let deliveriIndex = 2; //Номер позиции Самовывоза в списке
let discountTrigger = "price";
let codeList = [
[ 50, '10%' , 'DELIVERY' ], //Промокод в системе и размер его скидки в процентах
];
deliveriIndex--;
let triggerValue=0;
let currentDiscount = [];
let upswing=false;
let saveinputPC='';
let cartID = $('div[data-record-type="706"]').attr('id').replace(/[^0-9]/g, '');
let pcLid = $('.t-input-group_pc').attr('data-input-lid');
setTimeout(function(){ saveinputPC = $('.t-inputpromocode__wrapper').html()}, 1000);
function getDiscountInfo(trval){
let prevLine = 0;let minTotal = 0;
for(let i=0;i<codeList.length;i++){
if(trval >= codeList[i][0] && codeList[i][0] > prevLine ){prevLine = codeList[i][0];
for (let j=0;j<2;j++){currentDiscount[j]=codeList[i][j+1]};upswing=true;
}else if(trval < codeList[i][0]) minTotal++;
};
let radioIdx = $('input.t-radio_delivery').index($('input.t-radio_delivery:checked'));
if (minTotal == codeList.length && upswing || radioIdx!=deliveriIndex ) {
currentDiscount = [];clearDiscount();upswing=false;
if(pcLid != undefined ){
$('.t-input-group_pc').show();
$('.t-inputpromocode__wrapper').html(saveinputPC);
t_input_promocode_init(cartID,pcLid);
};
};
if(currentDiscount.length && radioIdx==deliveriIndex ){
$('.t-input-group_pc').hide();
window.tcart.promocode = {};
let totalWrap = $('.t706__cartwin-totalamount-wrap');
if(currentDiscount[0].indexOf('%') > 0 ){
window.tcart.promocode.discountpercent = (+currentDiscount[0].replace(/[^0-9.]/g, '')).toFixed(2);
clearTotalWrapClass();totalWrap.addClass('prcode_act_percent');
}else{
window.tcart.promocode.discountsum = currentDiscount[0]
clearTotalWrapClass();totalWrap.addClass('prcode_act_summ');
};
window.tcart.promocode.message = "OK";
window.tcart.promocode.promocode = currentDiscount[1];
tcart__updateTotalProductsinCartObj();
};
};
function clearTotalWrapClass(){ $('.t706__cartwin-totalamount-wrap').removeClass('prcode_act_percent prcode_act_summ')};
function clearDiscount(){
if ( window.tcart.hasOwnProperty("promocode") ){
delete window.tcart.promocode; tcart__updateTotalProductsinCartObj();clearTotalWrapClass();
};
};
$(".t706__cartwin-prodamount").bind( 'DOMSubtreeModified',function() {
if (discountTrigger=="price"){triggerValue = window.tcart.prodamount;}else{triggerValue = window.tcart.total}; getDiscountInfo(triggerValue);
});
});
</script>
<style>
.t706__cartwin-totalamount-wrap {
display: block !important;
order: -1;
margin-bottom: 25px;
}
span.t706__cartwin-totalamount-label:before {
content: "Сумма к оплате:";
position: absolute;
right: 10px;
width: 300%;
color: #000;
}
span.t706__cartwin-totalamount-label, .prcode_act_percent .t706__cartwin-totalamount-info span:nth-of-type(3) {
position: relative;
color: transparent;
}
.prcode_act_percent .t706__cartwin-totalamount-info span:nth-of-type(3):before {
content: "Скидка за самовывоз:";
position: absolute;
right: 1px;
width: 300%;
color: #000;
}
.prcode_act_summ .t706__cartwin-totalamount-info span:nth-of-type(3),
.prcode_act_summ .t706__cartwin-totalamount-info span:nth-of-type(4),
.prcode_act_summ .t706__cartwin-totalamount-info span:nth-of-type(4)+br {
display: none;
}
.t706 .t-form__inputsbox {
display: flex;
flex-direction: column;
}
.t706__cartwin-bottom {display: none}
.t706__orderform { margin-top: -5px}
</style>
<script>
$(document).ready(function(){
let paymentIndex = 2; //Номер позиции Оплаты в списке
let discountTrigger = "price";
let codeList = [
[ 50, '5%' , 'ONLINE' ], //Промокод в системе и размер его скидки в процентах
];
paymentIndex--;
let triggerValue=0;
let currentDiscount = [];
let upswing=false;
let saveinputPC='';
let cartID = $('div[data-record-type="706"]').attr('id').replace(/[^0-9]/g, '');
let pcLid = $('.t-input-group_pc').attr('data-input-lid');
setTimeout(function(){ saveinputPC = $('.t-inputpromocode__wrapper').html()}, 1000);
function getDiscountInfo(trval){
let prevLine = 0;let minTotal = 0;
for(let i=0;i<codeList.length;i++){
if(trval >= codeList[i][0] && codeList[i][0] > prevLine ){prevLine = codeList[i][0];
for (let j=0;j<2;j++){currentDiscount[j]=codeList[i][j+1]};upswing=true;
}else if(trval < codeList[i][0]) minTotal++;
};
let radioIdx = $('input.t-radio_payment').index($('input.t-radio_payment:checked'));
if (minTotal == codeList.length && upswing || radioIdx!=paymentIndex ) {
currentDiscount = [];clearDiscount();upswing=false;
if(pcLid != undefined ){
$('.t-input-group_pc').show();
$('.t-inputpromocode__wrapper').html(saveinputPC);
t_input_promocode_init(cartID,pcLid);
};
tcart__updateTotalProductsinCartObj();
tcart__reDrawTotal();
};
if(currentDiscount.length && radioIdx==paymentIndex ){
$('.t-input-group_pc').hide();
window.tcart.promocode = {};
let totalWrap = $('.t706__cartwin-totalamount-wrap');
if(currentDiscount[0].indexOf('%') > 0 ){
window.tcart.promocode.discountpercent = (+currentDiscount[0].replace(/[^0-9.]/g, '')).toFixed(2);
clearTotalWrapClass();totalWrap.addClass('prcode_act_percent');
}else{
window.tcart.promocode.discountsum = currentDiscount[0]
clearTotalWrapClass();totalWrap.addClass('prcode_act_summ');
};
window.tcart.promocode.message = "OK";
window.tcart.promocode.promocode = currentDiscount[1];
tcart__updateTotalProductsinCartObj();
tcart__reDrawTotal();
};
};
function clearTotalWrapClass(){ $('.t706__cartwin-totalamount-wrap').removeClass('prcode_act_percent prcode_act_summ')};
function clearDiscount(){
if ( window.tcart.hasOwnProperty("promocode") ){
delete window.tcart.promocode; tcart__updateTotalProductsinCartObj();clearTotalWrapClass();
};
};
function setDiscountStart(){
setTimeout(function(){
if (discountTrigger=="price"){triggerValue = window.tcart.prodamount;}else{triggerValue = window.tcart.total}; getDiscountInfo(triggerValue);
}, 500);
};
setDiscountStart();
$('input.t-radio_payment, .t706__carticon , a[href^= "#order"]').on('click', function() { setDiscountStart(); });
});
</script>
<style>
.t706__cartwin-totalamount-wrap {
display: block !important;
}
span.t706__cartwin-totalamount-label:before {
content: "Сумма к оплате:";
position: absolute;
right: 10px;
width: 300%;
color: #000;
}
span.t706__cartwin-totalamount-label, .prcode_act_percent .t706__cartwin-totalamount-info span:nth-of-type(3) {
position: relative;
color: transparent;
}
.prcode_act_percent .t706__cartwin-totalamount-info span:nth-of-type(3):before {
content: "Скидка за on-line оплату:";
position: absolute;
right: 1px;
width: 300%;
color: #000;
}
.prcode_act_summ .t706__cartwin-totalamount-info span:nth-of-type(3),
.prcode_act_summ .t706__cartwin-totalamount-info span:nth-of-type(4),
.prcode_act_summ .t706__cartwin-totalamount-info span:nth-of-type(4)+br {
display: none;
}
.t706 .t-form__inputsbox {
display: flex;
flex-direction: column;
}
.t706__cartwin-bottom {display: none}
</style>