Untitled

 avatar
unknown
plain_text
2 years ago
956 B
11
Indexable


<script>

window.SLIDECART_REMOVED_FROM_CART = async function({ id }) {
// Fires whenever an item is removed from cart
let responsevariant = await fetch(`/variants/${id}.json`, {method: 'GET'});
let allVariantInfo = await responsevariant.json();

let responseprod = await fetch(`/products/${allVariantInfo.product_variant.product_id}.json`, {method: 'GET'});
let allProductInfo = await responseprod.json();

console.log(allVariantInfo);
console.log(allProductInfo);


dataLayer.push({
event: "ga4_remove_from_cart",
items: [{
'item_id': '{{ product.id }}',
'item_name': '{{ product.title | remove: "'" | remove: '"' }}',
'item_brand': '{{ product.vendor | remove: "'" | remove: '"' }}',
'item_category': '{{ product.collections[0].title | remove: "'" | remove: '"' }}',
'variant_id': '{{ product.selected_variant.sku }}',
'currency': '{{ shop.currency }}',
'price': '{{ product.price | times: 0.01}}'
}]
});

}

</script>
Editor is loading...