Solved

Liquid validation based on any single element from 1 array matching any single elements from another

khard
Shopify Partner
22 1 8

I have 2 arrays and I want to validated if any element in array1 equals any element in array 2. 

Specifically, if any customer tags equals any tags in list of tags held in comma separated metafield.

Accepted Solution (1)

iDoThemes
Trailblazer
207 43 91

This is an accepted solution.

You should only need to loop through the customer tags, and check if the metafield contains the tag:

 

    {% for tag in customer.tags %}
      {% if your.metafield contains tag %}
          <!--   	Do stuff	 -->
      {% endif %}
    {% endfor %}

 

Developer of Liquify Chrome Extension -- Enhance the Shopify Theme Code Editor
.




Theme Developer -- Drop me a line

View solution in original post

Replies 2 (2)

iDoThemes
Trailblazer
207 43 91

This is an accepted solution.

You should only need to loop through the customer tags, and check if the metafield contains the tag:

 

    {% for tag in customer.tags %}
      {% if your.metafield contains tag %}
          <!--   	Do stuff	 -->
      {% endif %}
    {% endfor %}

 

Developer of Liquify Chrome Extension -- Enhance the Shopify Theme Code Editor
.




Theme Developer -- Drop me a line
khard
Shopify Partner
22 1 8

Ah, yes! Thank you!