Skip to main content
Solved

Using Shopify Tags in a Template

  • June 9, 2023
  • 1 reply
  • 270 views

Forum|alt.badge.img+2

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!

Best answer by bsck_dev

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! 

1 reply

Forum|alt.badge.img+2
  • Author
  • Contributor I
  • 1 reply
  • Answer
  • June 9, 2023

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!