πEnable Embed App
Last updated
// Some code
{% assign result_collection = "" %}
{% for collection in card_product.collections %}
{% if forloop.first == false %}
{% assign result_collection = result_collection | append: "," %}
{% endif %}
{% assign result_collection = result_collection | append: collection.id %}
{% endfor %}
<div class="omg-discount-notification" data-product-id="{{ card_product.id }}" data-collections="{{ result_collection }}" ></div>
<script>
if (typeof window.omgProductList === "undefined") {
window.omgProductList = [];
}
(function(){
const product = {
id: {{ card_product.id | json }},
title: {{ card_product.title | json }},
handle: {{ card_product.handle | json }},
variants: [
{% for variant in card_product.variants %}
{
id: {{ variant.id | json }},
title: {{ variant.title | json }},
price: {{ variant.price | json }},
available: {{ variant.available | json }}
}
{% unless forloop.last %},{% endunless %}
{% endfor %}
]
};
const productExists = window.omgProductList.some(p => p.id === product.id);
if (!productExists) {
window.omgProductList.push(product);
}
})();
</script>