<style>
.dis-order-btn{
pointer-events:none;
opacity:0.3;
}
.zproduct-image .tn-atom {background-size: cover}
.outofstock{background-color: #ff0000 !important}
div[data-record-type="776"]{display:none}
</style>
<script>
document.addEventListener("DOMContentLoaded", function(){
let storeLoad = setInterval(function() {
if (document.querySelector('.js-product.t-store__card_hidden')){
}else{
clearInterval(storeLoad);
setTimeout(function(){
let zeroBtn = document.querySelectorAll('a[href^="#zeroproduct-"]');
for (let i = 0; i < zeroBtn.length; i++) {
let zeroCard = zeroBtn[i].closest('.t-rec');
let prodId = zeroBtn[i].getAttribute('href').replace(/[^0-9]/g,"");
let product = ''; let ch = 0;
let cardLoad = setInterval(function() {
product = document.querySelectorAll('div.js-product[data-product-lid="'+prodId+'"]');
if (product.length && ch<50){
product = product[0];
clearInterval(cardLoad);
zeroBtn[i].addEventListener('click', function() {
product.querySelector('a').click();
});
let specifications = {};
specifications['quant'] = product.getAttribute('data-product-inv');
specifications['title'] = product.querySelector('.js-store-prod-name').innerText;
specifications['sku'] = product.querySelector('.js-store-prod-sku').innerText;
specifications['price'] = product.querySelector('.js-product-price').innerText;
specifications['image'] = product.getAttribute('data-product-img');
zeroCard.querySelector('.zproduct-title .tn-atom').innerText = specifications['title'];
zeroCard.querySelector('.zproduct-sku .tn-atom').innerText = 'ART: '+specifications['sku'];
zeroCard.querySelector('.zproduct-price .tn-atom').innerText = specifications['price']+' ₽';
zeroCard.querySelector('.zproduct-quant .tn-atom').innerText = 'Количество: '+specifications['quant']+' шт';
zeroCard.querySelector('.zproduct-image .tn-atom').style.backgroundImage = 'url('+specifications["image"]+')';
if(specifications['quant']=='0'){
zeroCard.querySelector('a[href^="#zeroproduct-"]').classList.add('dis-order-btn');
zeroCard.querySelector('.zproduct-instock[data-elem-type="text"] .tn-atom').innerText = 'Нет в наличии';
zeroCard.querySelector('.zproduct-instock[data-elem-type="shape"] .tn-atom').classList.add('outofstock');
};
if(specifications['quant']==''){
zeroCard.querySelector('.zproduct-quant .tn-atom').innerText = 'Количество: ∞';
};
}else{
ch++;
if(ch>50){
clearInterval(cardLoad);
console.log('Product not found. Check prod ID');
};
};
}, 100);
};
}, 1000);
}
}, 100);
});
</script>