<script>
document.addEventListener("DOMContentLoaded", function(){
(function () {
let snippetSearchRepeat = 0;
let tistore = setInterval(function() {
const productListNum = document.querySelector('.t-store__product-snippet');
if(productListNum) {
if(productListNum.hasAttribute("data-product-url")){
clearInterval(tistore);
sendConveadAction(true);
};
};
snippetSearchRepeat++;
if(snippetSearchRepeat>50) clearInterval(tistore);
}, 100);
function sendConveadAction(em){
setTimeout(function(){
let productCard = '';
if(em){
productCard = document.querySelector('.t-store__product-snippet');
}else{
productCard = document.querySelector('.t-store .t-popup_show .t-store__product-popup');
};
if(productCard!=null){
const prName = productCard.querySelector('.js-store-prod-name').innerText;
const prID = productCard.getAttribute('data-product-uid');
const prURL = productCard.getAttribute('data-product-url');
convead('event', 'view_product', {
product_id: prID,
product_name: prName,
product_url: prURL
});
console.log(prName);
};
}, 300);
};
document.addEventListener('click', function(event) {
if(event.target.closest('a[href*="/tproduct/"]')){
setTimeout(function () { sendConveadAction(false) }, 300);
};
});
})();
});
</script>
<script>
document.addEventListener("DOMContentLoaded", function() {
(function() {
let prodListArr = [];
function sendConveadAction2() {
setTimeout(function() {
prodListArr = [];
const cartProducts = window.tcart.products;
for (let i = 0; i < cartProducts.length; i++) {
let prodListObj = {};
prodListObj['product_id'] = cartProducts[i]['uid'];
prodListObj['qnt'] = cartProducts[i]['quantity'];
let price = cartProducts[i]['amount'];
if (cartProducts[i]['amount_withdiscount'] != undefined) {
price = cartProducts[i]['amount_withdiscount'];
}
prodListObj['price'] = price;
prodListArr.push(prodListObj);
}
console.log(prodListArr);
convead('event', 'update_cart', {
items: prodListArr
});
}, 300);
}
setTimeout(function() {
const prodamount = document.querySelector('.t706__carticon-counter');
if (prodamount != null) {
const observer = new MutationObserver(mutationRecords => {
sendConveadAction2();
});
observer.observe(prodamount, {
childList: true,
subtree: true,
characterDataOldValue: true
});
}
}, 1500);
})();
});
</script>