Finding specific product tag in Javascript?

New Member
1 0 0

Hi all, 

I am working on this line of JS in my theme (Impulse), and am a bit stuck on how to properly write it:


delayMessage: product.product_tags.includes('Tees'),

Essentially I am looking to define 'delayMessage' by the product tag 'Tees', however I cannot figure out how to find that specific tag in Javascript using the product object.

I've tried the following as well, however can't seem to get it to work:


delayMessage: product_tags == 'Tees',
delayMessage: product.product_tags == "Tees",
delayMessage: product.tags.includes('Tees'),

What would be the correct way to write this? As products normally have multiple tags, do you need to loop through them similar to liquid?

Shopify Expert
10170 135 1906

So it looks like you've got a product object created, but what are the contents of that?
I don't have the theme handy but that's a good place to start.

Depending on how that object is constructed I'd expect the tags to either be an array, or a just a string of comma separated values. Knowing the data structure helps us move on too many more assumptions.

If there's a public link that makes this clearer for the forum members without having to dive into a giant explanation, then share that instead.

I jump on these forums to help and share some insights. Not looking to be hired, and not looking for work.

Don't hand out staff invites or give admin password to forum members unless absolutely needed. In most cases the help you need can be handled without that.

★ ★