-
Notifications
You must be signed in to change notification settings - Fork 58
/
wishlist-product.liquid
28 lines (25 loc) · 1.08 KB
/
wishlist-product.liquid
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{% capture id %}{{ product.id }}{% endcapture %}
{% for tag in customer.tags %}{% if tag contains id %}{% assign t = tag %}{% endif %}{% endfor %}
{% assign check = t.size | minus:id.size | modulo:2 %}
{% if check == 0 %}{% assign display = true %}{% endif %}
{% if display %}
<a class="wishlist" href="javascript:void(0)"><i class="fa fa-heart-o"></i> Save to my Wishlist</a>
{% else %}
<a href="/collections/wish-list"><i class="fa fa-heart-o"></i> Saved to Wishlist</a>
{% endif %}
<p class="wish-error" style="display:none">To add this product to your favorites you must <a href="/account">sign in</a> or <a href="/account/register">create an account</a>.</p>
{% form 'customer' %}
<input type="hidden" name="contact[email]" value="{{ customer.email }}"/>
<input type="hidden" name="contact[tags]" value="{% if t.size > 0 %}x{{ t }}{% else %}{{ product.id }}{% endif %}" />
{% endform %}
{% if display %}
<script>
$('.wishlist').click(function() {
{% if customer %}
$('.contact-form').submit();
{% else %}
$('.wish-error').show();
{% endif %}
});
</script>
{% endif %}