# Multiple hasAnyTag elements

**URL:** <https://community.shopify.com/t/multiple-hasanytag-elements/199038>\
**Category:** Functions\
**Tags:** optimization\
**Created:** [March 13, 2023, 5:24am UTC](https://community.shopify.com/t/multiple-hasanytag-elements/199038 "2023-03-13T05:24:48Z")\
**Posts on this page:** 6\
**Page:** 1

## AI-generated summary

Main issue: hasAnyTag on cart.buyerIdentity.customer was always returning true when checking different customer tags to hide specific payment methods.

Recent update: A platform-side issue was fixed by staff; the original reporter confirmed the function now behaves correctly.

Correct usage for multiple tags: 
- Use an array of separate strings: hasAnyTag(tags: ["tag1", "tag2"]). This returns true if the customer has any of the listed tags. 
- Do not combine tags into a single string (e.g., "tag1,tag2" or "tag1 tag2"), which evaluates to false.

Context and alternatives: 
- The goal is to conditionally hide payment methods based on customer tags via cart.buyerIdentity.customer.hasAnyTag. 
- For product tag checks, an alternative is product.hasTags(tags: $tags), which returns a list of matches with fields { hasTag, tag } to see which tags are present.

Status: Resolved. The prior bug was fixed, and the correct syntax for multiple tag checks is clarified. Code snippets are central for implementation.

<div class="post-metadata">

**Author:** ![agastify](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@agastify](https://community.shopify.com/u/agastify)\
**Post date:** [March 13, 2023, 5:24am UTC](https://community.shopify.com/t/multiple-hasanytag-elements/199038/1 "2023-03-13T05:24:48Z")

</div>

Hi,

I am looking to hide the Cash on Delivery payment method for customers tagged with “tag1”, and hide another payment method for customers tagged with “tag2”. However, I’m having trouble implementing this.

I have tried using the code below, but it seems to always return true for both hasAnyTag fields:

```css
query Input {
  cart {
    buyerIdentity {
      customer{
        hasAnyTag(tags: ["tag1"])
        hasAnyTag2 : hasAnyTag(tags: ["tag2"])
        
      }
    }
  }
}

```

Could you please advise on the correct code to achieve this? Thank you for your assistance.

@Nick_Wesselman

---

<div class="post-metadata">

**Author:** ![Nick\_Wesselman](https://yyz1.discourse-cdn.com/shopifyforum/user_avatar/community.shopify.com/nick_wesselman/32/309011_2.png) [@Nick\_Wesselman](https://community.shopify.com/u/Nick_Wesselman)\
**Post date:** [March 16, 2023, 8:05pm UTC](https://community.shopify.com/t/multiple-hasanytag-elements/199038/2 "2023-03-16T20:05:44Z")

</div>

Hi @agastify – This issue should now be resolved!

---

<div class="post-metadata">

**Author:** ![agastify](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@agastify](https://community.shopify.com/u/agastify)\
**Post date:** [March 17, 2023, 8:18am UTC](https://community.shopify.com/t/multiple-hasanytag-elements/199038/3 "2023-03-17T08:18:47Z")

</div>

It works well now. Thank you for your assistance.

[@Nick\_Wesselman](https://community.shopify.com/user/1197220)

---

<div class="post-metadata">

**Author:** ![Acariah](https://avatars.discourse-cdn.com/v4/letter/a/a9a28c/32.png) [@Acariah](https://community.shopify.com/u/Acariah)\
**Post date:** [April 18, 2023, 5:04pm UTC](https://community.shopify.com/t/multiple-hasanytag-elements/199038/4 "2023-04-18T17:04:56Z")

</div>

Hey Nick,

I have a similar question. I have a feeling the answer was in this thread, but it looks like the solution has gone missing! Would you be able to repost?

Thanks!

Edit: For context, I am also attempting to check for multiple tags using `hasAnyTags` with little success.

I have tried the following:

hasAnyTag(tags: [“tag1,tag2”]) - always evaluates to `false`  
hasAnyTag(tags: [“tag1 tag2”]) - always evaluates to `false`  
hasAnyTag(tags: [“tag1”, “tag2”]) - always evaluates to `true`

---

<div class="post-metadata">

**Author:** ![agastify](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@agastify](https://community.shopify.com/u/agastify)\
**Post date:** [April 18, 2023, 8:15pm UTC](https://community.shopify.com/t/multiple-hasanytag-elements/199038/5 "2023-04-18T20:15:30Z")

</div>

Hi @Acariah

This is the correct format

hasAnyTag(tags: [“tag1”, “tag2”])

it will match any of tag1 or tag2

---

<div class="post-metadata">

**Author:** ![yash100ni](https://yyz1.discourse-cdn.com/shopifyforum/user_avatar/community.shopify.com/yash100ni/32/368395_2.png) [@yash100ni](https://community.shopify.com/u/yash100ni)\
**Post date:** [November 10, 2025, 3:59pm UTC](https://community.shopify.com/t/multiple-hasanytag-elements/199038/8 "2025-11-10T15:59:03Z")

</div>

@agastify You can also use hasTag field to get all object tags  
query Input($tags: [String!]!) {  
cart {  
lines {  
merchandise {  
…on ProductVariant {  
product {  
hasTags(tags: $tags) {  
hasTag  
tag  
}  
}  
}  
}  
}  
}  
}
