How to get one of product tags via get product data (Right formula)

As u see, i have one product with many tags, one of them is " '- tag__sale_Coming Soon "(*As below pictures show ).

This flow is designed for "every day the flow check if any product‘s status is active and inventory >0, especially has one specific tag '- tag__sale_Coming Soon ", then remove this tag and a new tag.

So my question is how should i write its advanced queries:

1, status:active and inventory_total:>0 AND tag:"'- tag__sale_Coming Soon**"**, whether should i add “”(quotes) in it due to one whitespace here.

2, status:active and inventory_total:>0 AND tag contains sale_Coming, if wanna retrieve it using part of this specific tag, could i use “contains” in this situation?

3, Is there any issue that i need to pay attention to?

Really appreciate anything u will say!

1 Like

You can’t do a tag contains query filter. It only will do exact matches for tags. I’d recommend not using special characters in the tag names just because it might get kind of confusing and you could run into conflicts.

Thank u Kalen, the special characters are what the used theme requires. appreciate your sharing and pro guidance.

1 Like

Ah I see. Should be possible to use those as long as you’re doing exact matches.

so should i still remove the double quotation marks? what’s the right formula that i need when there is a special character and a blankspace?

You need the double quotes. Single quotes might also work.

I recommend testing your query before you try to run actions based on it. You can either use something like an API client, or GraphiQL. Or you can put an action after the Query to output what it retrieves (I use the Log Output action). That way you don’t have to just hope it works.

This article has good details about how to test and see data/output: https://help.shopify.com/en/manual/shopify-flow/reference/data

Thank u, Paul. it works, and one more question, did u know if i use “contains” as the operator, how to write it for “edit query”?

I tried “status:active and inventory_total:>0 AND tag contains sale_Coming” and “status:active and inventory_total:>0 AND tag contains “Coming Soon”, but all failed. do u know where the errors are? and how to fix them?

Thank u in advance!

“Contains” isn’t a valid operator in queries. The UI links you to some docs on how to write various queries. https://shopify.dev/docs/api/usage/search-syntax

That said, I’ve heard you cannot use the partial matching search with tags. That might not be true, but test it first.

1 Like

Got it, thank u