"If" based on customer tags

Solved
Highlighted
New Member
5 0 0

Hi,

 

Certain products we sell are visible to all customers but only purchasable by our dealers. We have a different product template which achieves this. The following code in the altered product template was previously working but is not working any more and I am at a loss as to why.

 

{% if customer.tags contains 'Dealer' or 'dealer' %}
{%else%}
<span class=""> This product can only be purchased through a <a href="https://ecoinnovation.myshopify.com/pages/find-a-dealer">dealer</a>. if you are a dealer please <a href="https://ecoinnovation.myshopify.com/account/login">log in</a>
<span class="" ></span>
{%endif%}

 

Any thoughts on possible causes are much appreciated.

 

0 Likes
Highlighted
Shopify Expert
1381 111 200

please share a store url

0 Likes
Highlighted
Shopify Expert
2684 67 778

This is an accepted solution.

Mate, this code is wrong:

{% if customer.tags contains 'Dealer' or 'dealer' %}

it should be like:

{% if customer.tags contains 'Dealer' or customer.tags contains 'dealer' %}

(I'd guess that it always shows the warning, since "dealer" is evaluated to true for  the purposes of the if  tag. And it was working before someone added the second condition?)

Want to hire me to tweak a theme? Mail me at tairli@yahoo.com!
My post solved your problem? Like it!
I am away till Feb-15.
0 Likes
Highlighted
New Member
5 0 0
Thank you so much for taking the time to help me learn. I really appreciate it.
0 Likes