<style>
/* Основные стили корзины */
.t706__body_cartwinshowed {
height: auto;
min-height: auto;
overflow: auto;
}
.t706__cartwin {
display: block;
position: static;
background: #fff;
overflow: unset;
opacity: 1 !important;
}
.t706__cartwin-content {
position: relative;
max-width: 1200px;
height: 100%;
padding: 40px 20px;
margin: 0 auto;
background: #fff;
overflow: unset;
}
@media (min-width: 960px) {
.t706__cartwin-content {
display: flex;
}
.t706__orderform {
max-width: 40%;
width: 100%;
margin-left: auto;
}
.products-fixed-list {
position: sticky;
align-self: flex-start;
top: 20px;
max-width: 50%;
width: 100%;
}
}
.t706__cartwin-close,
.t706__carticon {
display: none;
}
.t706__form-upper-text {
padding-top: 0;
}
/* Фикс скролла (был в отдельном коде) */
body {
overflow: auto !important;
}
</style>
<script>
$(document).ready(function() {
// Автоматически открываем корзину
setTimeout(function() {
t_onFuncLoad('tcart__openCart', function() {
tcart__openCart();
});
}, 1000);
// Оптимизация структуры
$('.t706__cartwin-top, .t706__cartwin-products, .t706__cartwin-bottom').wrapAll('<div class="products-fixed-list"></div>');
$('.t706__orderform').append($('.t706__form-bottom-text'));
$('.t706__orderform').prepend($('.t706__form-upper-text'));
});
</script>
<style>
.blkElem{pointer-events:none; }
.cartcopyanim {
-webkit-animation: t706__pulse-anim 0.6s;
animation: t706__pulse-anim 0.6s;}
.cartcopy_elem .tn-atom , .cartprice_elem .tn-atom {display:none}
.cartcopy{cursor:pointer}
.t706__carticon {display: none !important;}
</style>
<script>
$(document).ready(function() {
let hideMode = false; //Скрыть-Показать пустую корзину - true-false
$('.cartcopy_elem .tn-atom').addClass('cartcopy');
$('.cartprice_elem .tn-atom').addClass('cartcopyprice');
function updateCartInfo() {
if(!hideMode) $('.cartcopy, .cartcopyprice').show();
let chCounter = window.tcart?.total || 0;
let chPrice = window.tcart?.prodamount || 0;
if (chPrice == 0) {
$('div[data-elem-type="text"] .cartcopyprice').html('');
if(hideMode) {
$('.cartcopy, .cartcopyprice').hide();
} else {
$('.cartcopy, .cartcopyprice').show();
}
} else {
$('div[data-elem-type="text"] .cartcopyprice').html(chPrice+' руб');
if(hideMode) $('.cartcopy, .cartcopyprice').show();
};
$('div[data-elem-type="text"] .cartcopy').html(chCounter);
if(chCounter == 0) {
$('.cartcopy').addClass('blkElem');
} else {
$('.cartcopy').removeClass('blkElem');
};
if(chCounter == '') {
$('div[data-elem-type="text"] .cartcopy').html(0);
};
// Добавляем анимацию при изменении
if(chCounter > 0) {
$('.cartcopy').addClass('cartcopyanim');
setTimeout(function(){
$('.cartcopy').removeClass('cartcopyanim');
}, 1000);
}
}
// Первоначальное обновление
setTimeout(updateCartInfo, 500);
// Обновляем при изменении корзины
$(document).on('tilda:cart:updated', updateCartInfo);
// Альтернативный способ отслеживания изменений
setInterval(updateCartInfo, 1000);
// Открытие корзины по клику
$('.cartcopy').click(function(e) {
e.preventDefault();
tcart__openCart();
});
});
</script>