1document.addEventListener("DOMContentLoaded", function () { 2 document.body.addEventListener("click", function (event) { 3 const anchor = event.target.closest("a"); 4 5 if (anchor && anchor.classList.contains("remove_from_cart_button")) { 6 const cartList = document.querySelector(".woocommerce-mini-cart"); 7 const cartItems = [ 8 ...cartList.querySelectorAll(".woocommerce-mini-cart-item"), 9 ]; 10 11 // Find the clicked item's index 12 const clickedItem = anchor.closest(".woocommerce-mini-cart-item"); 13 const productId = anchor.getAttribute("data-product_id"); 14 const productName = anchor 15 .getAttribute("aria-label") 16 ?.replace("Remove ", "") 17 .replace(" from cart", ""); 18 19 const container = anchor.closest(".line-item-container"); 20 let price = null; 21 22 if (container) { 23 const priceElement = container.querySelector(".item-price"); 24 if (priceElement) { 25 price = parseFloat(priceElement.textContent.trim().replace("â¹", "")); 26 } 27 } 28 29 window.dataLayer = window.dataLayer || []; 30 window.dataLayer.push({ ecommerce: null }); // Clear previous data 31 32 window.dataLayer.push({ 33 event: "remove_from_cart", 34 ecommerce: { 35 currency: "INR", 36 value: price, 37 items: [ 38 { 39 item_id: productId, 40 item_name: productName, 41 price: price, 42 quantity: 1, 43 }, 44 ], 45 }, 46 }); 47 } 48 }); 49});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.