Solved

Using Shopify Tags in a Template

  • 9 June 2023
  • 1 reply
  • 134 views

Badge

Hi guys,

I've got a tricky use-case where essentially we're tagging customers using the Shopify Tags field with a "before" and "after" size after they take a quiz.

E.g.
Before Size: 10
After Size: 12

Syncs to Klaviyo fine - but I'm wondering how to extract a particular tag?

e.g. loop through the tags, and if a tag contains “Before Size” or “After Size”, extract it.

Once we extract the tag, can use a slice filter, I assume, to remove the "Before Size:" bit?

The tag may not always be in a fixed position in the index/array of tags, either - so can’t use a hardcoded index number.

Any advice welcome!

icon

Best answer by bsck_dev 9 June 2023, 20:48

View original

1 reply

Badge

Ah! Have solved it - I can loop through the tags and use an if + in statement: 

{% for tag in person|lookup:'Shopify Tags' %}
{% if "After Size" in tag %}
Your new size: {{tag |slice:'13:15'}}</a>
{%endif%}
{% endfor %}

 

Not sure if it’s the best way, but it works! 

Reply