Skip to content
{
const itemCountInCart = $store.cart.data
.items.filter(i => i.variant_id == product)
.reduce((total, item) => total + (item.quantity || 0), 0);
if (!itemCountInCart) {
$store.cart.addCartItem(product, 1);
}
else if (itemCountInCart > 1) {
$store.cart.updateCartItem(product, 1); // Never more than one.
}
})
"
>