"10764067087" ,"12005132367" ,"10768226575"]} ); function isRelevantCartUpdate(settings) { function dataContains(term) { return settings.data && settings.data.indexOf && settings.data.indexOf(term) > -1; } return (settings.url == "/cart/add.js" || settings.url == "/cart/update.js") && ( dataContains('attributes[prod') || (dataContains('id=') && dataContains('quantity=')) ); } $(document).ajaxSuccess(function(event, xhr, settings) { if (isRelevantCartUpdate(settings)) { $.getJSON("/cart.js", function(data) { var basketData = []; var item; if (!data.items || !data.items.length) return; for (var i = 0; i < data.items.length; i++) { item = data.items[i]; basketData.push({ id: "shopify_US_" + item.product_id + "_" + item.variant_id, price: priceFromCents(item.price), quantity: item.quantity }); } window.criteo_q.push({ event: "viewBasket", product: basketData }); }); } }); })();