I’m encountering an issue with the Shopify GraphQL API when trying to set up customization rules based on customer tags. Here’s the situation:
I’ve created a rule where users can specify a tag for a customer. This involves the following conditions:
- Condition Option:
CustomerTag
- Condition:
Contains
- A field is provided for the user to input the desired customer tag (e.g.,
TestingC-Tag
).
The tag is successfully added and saved in the Shopify Admin under Customers Settings. However, when I query the hasTags
field in the buyerIdentity.customer
object, it is returning false
for the hasTag
property, even though the tag exists for the customer.
GraphQL Query:
buyerIdentity {
email
customer {
email
amountSpent {
amount
}
hasTags(tags: $customerTags) {
tag
hasTag
}
}
}
run.graphql :
query RunInput($customerTags: [String!], $productTags: [String!]) {
cart {
discountCodes: attribute(key: "discountCodes") {
key
value
}
zoneProvince: attribute(key: "Zone") {
key
value
}
cost {
totalAmount {
amount
}
totalTaxAmount{
amount
}
subtotalAmount {
amount
}
}
lines {
quantity
cost{
amountPerQuantity{
amount
}
compareAtAmountPerQuantity{
amount
}
}
merchandise {
... on ProductVariant {
sku
weight
product {
hasTags(tags: $productTags) {
tag
hasTag
}
}
}
}
}
deliveryGroups {
deliveryAddress {
provinceCode
city
countryCode
}
selectedDeliveryOption {
cost {
amount
}
}
}
buyerIdentity {
email
customer {
email
amountSpent {
amount
}
hasTags(tags: $customerTags) {
tag
hasTag
}
}
}
}
paymentMethods {
id
name
}
paymentCustomization {
metafield(namespace: "$app:payment-customization-v2", key: "advance-rules") {
value
}
}
}
Result from Extensions Console:
{
"buyerIdentity": {
"email": "muhammadhassaankaleem1567@gmail.com",
"customer": {
"email": "muhammadhassaankaleem1567@gmail.com",
"amountSpent": {
"amount": "0.0"
},
"hasTags": [
{
"tag": "TestingC-Tag",
"hasTag": false
}
]
}
}
}
As you can see, the API is returning hasTag: false
for the tag "TestingC-Tag"
, even though it exists in the Shopify Admin for this customer.
Steps I’ve Taken:
- Verified that the tag
"TestingC-Tag"
is correctly added and visible in Shopify Admin under the customer’s profile. - Confirmed the GraphQL query syntax and input data.
- Rechecked the
customerTags
value being passed to ensure it matches the tag in Shopify Admin.
Question:
Why might the hasTags
field be returning false
for a tag that exists in Shopify Admin? how do i fix reslve it to use hasTag or is there any other solution to use CustomerTags?(upload://1x4hAQuec6b4dE5FxKhdA2uEPF8.png)