Multiple hasAnyTag elements

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:

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

Hi @agastify – This issue should now be resolved!

It works well now. Thank you for your assistance.

@Nick_Wesselman

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

Hi @Acariah

This is the correct format

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

it will match any of tag1 or tag2

@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
}
}
}
}
}
}
}