What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Multiple hasAnyTag elements

Solved

Multiple hasAnyTag elements

agastify
Shopify Partner
8 0 2

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 

Accepted Solution (1)

Nick_Wesselman
Shopify Staff
171 43 73

This is an accepted solution.

Hi @agastify -- This issue should now be resolved!

Nick Wesselman | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

View solution in original post

Replies 4 (4)

Nick_Wesselman
Shopify Staff
171 43 73

This is an accepted solution.

Hi @agastify -- This issue should now be resolved!

Nick Wesselman | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

agastify
Shopify Partner
8 0 2

It works well now. Thank you for your assistance.

@Nick_Wesselman 

Acariah
Shopify Partner
1 0 0

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`
agastify
Shopify Partner
8 0 2

Hi @Acariah 

This is the correct format

hasAnyTag(tags: ["tag1", "tag2"]) 

it will match any of tag1 or tag2