function addToCartAction (){ localCall('addToCart', {pickedProduct:pickedProduct}, (msg)=>{ refreshCart(msg); let btnadd = document.getElementById('addToCart'); if(btnadd){ btnadd.querySelector('.addedCart').style.display=""; btnadd.querySelector('.notaddedCart').style.display="none"; btnadd.classList.add('adaugat'); setTimeout(() => { btnadd.querySelector('.addedCart').style.display="none"; btnadd.querySelector('.notaddedCart').style.display=""; btnadd.classList.remove('adaugat'); }, 2000) } // -- //-- }, failAddToCart, 'POST'); if(typeof pickedProduct.name != 'undefined' && typeof ttq !== 'undefined'){ ttq.track('AddToCart',{ contents: [ { content_id: pickedProduct.id, content_name: pickedProduct.name.replace(/&/g, "&"), quantity: 1, price: pickedProduct.price, }], content_type: 'product', value: pickedProduct.price, currency: 'RON', }); } if(typeof pickedProduct.name != 'undefined' && typeof fbq == 'function'){ fbq('track', 'AddToCart', { content_name: pickedProduct.name.replace(/&/g, "&"), content_ids: [pickedProduct.id], content_type: 'product', value: pickedProduct.price, currency: 'RON' }); } if(typeof pickedProduct.name != 'undefined' && typeof gtag == 'function'){ gtag('event','add_to_cart', { value:pickedProduct.price, currency: 'RON' , items: [ { item_id: pickedProduct.id, google_business_vertical: 'retail', quantity: 1, item_name: pickedProduct.name.replace(/&/g, "&"), item_variant: pickedProduct.sizeText, item_category: pickedProduct.category, item_category2: pickedProduct.maincat } ] }); } if(typeof pickedProduct.name != 'undefined' && typeof glami == 'function'){ glami( 'track', 'AddToCart', { consent: 1, // The user's consent to the storage analytical cookies on their devices. [0 = no; 1 = yes] item_ids: [pickedProduct.id], // product ID currently added to a cart. Use the same ID as you use in the feed (ITEM_ID). value: pickedProduct.price, // product price currency: 'RON' // product price currency } ); } (rtbhEvents = window.rtbhEvents || []).push( { eventType: 'basketadd', offerId: (pickedProduct.familyId).toString() }, { eventType: 'uid', id: getCookie('idVisit') }); } function failAddToCart(msg){ gotError = JSON.parse(msg); if(gotError){ //alert(gotError.error_text); if(typeof gotError.error_detail !== 'undefined'){ let noti = document.getElementById('stockNotification'); if(noti){ noti.innerHTML = gotError.error_detail; noti.classList.add('ultimulProdus'); } } } } function showBigSlide(){ const clickk = this.dataset['order']; let pictures = document.getElementsByClassName('thumbImage'); let bigslide = document.getElementById('bigslide'); bigslide.innerHTML = ''; let nrpict =0 ; for(const pict of pictures){ let lislide = document.createElement('li'); lislide.innerHTML = ''; bigslide.append(lislide); nrpict++; } let imagefull = document.getElementById('imageFull'); if(imagefull){ document.getElementById('body').classList.add('hideOverflow'); imagefull.style.display = ''; document.getElementsByClassName bigslide.style.columns = nrpict; let bigcarousel = new Carousel('bigslide'); bigcarousel.addControls('arrowright1','arrowLeft1'); bigcarousel.goto(clickk); } } function getFullImageQuality(){ let pictures = document.getElementsByClassName('thumbImage'); for(const pict of pictures){ pict.addEventListener('click', showBigSlide); let dumyimg = new Image(); dumyimg.addEventListener('load',(event)=>{ pict.src = (pict.src).replace('thumbs/', 'photos/'); }); dumyimg.src = (pict.src).replace('thumbs/', 'photos/'); } } var count = 1; var countEl = document.getElementById("quantity"); function plus(){ count++; countEl.value = count; } function minus(){ if (count > 1) { count--; countEl.value = count; } } // click outside const specifiedElement = document.getElementById('selector'); if(specifiedElement){ document.getElementById('selector').addEventListener('click', function() { document.getElementById('selectorList').classList.toggle('viewSelect'); }); document.addEventListener('click', event => { const isClickInside = specifiedElement.contains(event.target) if (!isClickInside) { document.getElementById('selectorList').classList.remove('viewSelect'); } }) } let openSizes = document.getElementById('openSizes'); if(openSizes) openSizes.addEventListener('click', ()=>{ let tblmod = document.getElementById('tabelMarimi'); if(tblmod){ document.getElementById('body').classList.add('hideOverflow'); document.getElementById('overlay').classList.add('overlayed'); tblmod.style.display = "block"; } try{ localCall('logMarimi', {categoryId:pickedProduct.catId, brandId:pickedProduct.braId}, false, false, "POST"); }catch(e){ console.log(e) } }) let closeBtn = document.getElementsByClassName("closeParent"); Array.from(closeBtn).forEach(close => { if(!close.classList.contains('clickable')){ close.classList.add('clickable'); close.addEventListener('click', ()=> {document.getElementById('body').classList.remove('hideOverflow'); document.getElementById('overlay').classList.remove('overlayed'); close.parentNode.style.display = 'none'}); } }) function closePopups(t){ document.getElementById('body').classList.remove('hideOverflow'); document.getElementById('overlay').classList.remove('overlayed'); t.style.display = 'none'; } function getProductVariations(id){ localCall("getProductsVariations", 'id[]='+id, msg =>{ if(typeof msg.items[id] === 'undefined'){ console.log(msg); return false; } Object.values(msg.items[id]).forEach(sizeE => { console.log(sizeE); }); } , fail => {console.log(fail)}); } function pickThisProduct(){ let pa = this.attributes['data-value']; let va = parseInt(this.attributes['data-available'].value); let obsSizse = this.dataset['obssize']; //let si = this.attributes['data-size'].value; let sizetext = this.dataset['sizetext']; Array.from(document.getElementsByClassName('size-available')).forEach(ll => ll.classList.remove('selected')); if(pa && pa.value){ let dsl = document.getElementById('selectedItem'); if(dsl){ dsl.innerHTML = this.innerHTML+" - ";//put by sizeId if you want } this.classList.add('selected'); pickedProduct.id = pa.value; pickedProduct.sizeText = sizetext; if(sizetext){ pickedProduct.sizeText = sizetext; } let stoknot =document.getElementById('stockNotification'); if(va < 4 && va > 0){ if(va == 1){ stoknot.innerHTML = 'Ultimul produs'; }else{ stoknot.innerHTML = 'Ultimele '+(va.toString())+' produse'; } //stoknot.innerHTML = (va==1?"Ultimul":"Ultimele")+" "+(va>1?va:"")+" produs"+(va>1?"e":"")+"" }else{ stoknot.innerHTML = 'In stoc'; } } try{ (rtbhEvents = window.rtbhEvents || []).push( { eventType: 'size', size: pickedProduct.sizeText }, { eventType: 'uid', id: getCookie('idVisit') }); updateProductName(); if(typeof updateSizeDimensionsDetails !=='undefined'){ updateSizeDimensionsDetails(obsSizse); } }catch{ console.log('error name change'); } } function updateProductName(){ let mname = document.getElementById('mainProductName'); if(mname){ if(pickedProduct.sizeText != ''){ mname.innerHTML = pickedProduct.name+", "+pickedProduct.sizeText; document.title = pickedProduct.name+", "+pickedProduct.sizeText+ " "+pickedProduct.id+ ' | outletmag.ro'; } } try{ markSizeChart() }catch(e){ console.log(e); } } function markSizeChart(){ Array.from(document.getElementsByClassName('pickOneSizeRow')).forEach(trow => { let sizetxt = trow.dataset['sizetxt']; trow.classList.remove('suggested'); if(sizetxt == pickedProduct.sizeText){ trow.classList.add('suggested'); } }) if(typeof updateSizeDetails !=='undefined'){ updateSizeDetails(); } }