Solved

How to use metafield value/ dynamic value on hasAnyTag

ifat802
Shopify Partner
9 0 0
query Input {
  cart {
    buyerIdentity {
      customer {
        hasAnyTag(tags: ["vip"])
      }
    }
  }
  discountNode {
    metafield(namespace: "$app:order-discount", key: "function-configuration") {
      value
    }
  }
}

Here hasAnyTag has a hardcoded tag vip. 
I want to use dynamic tags here so that customers can set their own tags.
Can I use the Metafield value here?

Iftakhar
Accepted Solution (1)

Liam
Shopify Staff
2731 301 779

This is an accepted solution.

Hi Ifat802,

 

Have you looked into using variables in input queries - it sounds like this is what you'll need for using metafields in this context.

Hope this helps!

Liam | Developer Advocate @ 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 Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

Replies 3 (3)

Liam
Shopify Staff
2731 301 779

This is an accepted solution.

Hi Ifat802,

 

Have you looked into using variables in input queries - it sounds like this is what you'll need for using metafields in this context.

Hope this helps!

Liam | Developer Advocate @ 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 Shopify.dev or the Shopify Web Design and Development Blog

ifat802
Shopify Partner
9 0 0

Thanks, @Liam. I have figured out the solution. 

Iftakhar
Liam
Shopify Staff
2731 301 779

Great to hear!

Liam | Developer Advocate @ 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 Shopify.dev or the Shopify Web Design and Development Blog