Variables are not working on shop metafield for cart checkout validation function

Variables are not working on shop metafield for cart checkout validation function

harsh_mishra
Shopify Partner
3 0 0

I have created metafiled on shop which is working fine. However am unable to pass the variables.
in RunInput $selectedProducts supposed to send the values but it is not.

query RunInput($selectedProductTags: [String!], $selectedCollectionIds: [ID!]) {
  cart {
    lines {
      quantity
      merchandise {
        __typename
        ... on ProductVariant {
          id
          weight
          product {
         
            hasTags(tags: $selectedProductTags) {
              hasTag
              tag
            }
          }
        }
      }
    }
  }
  shop {
    metafield(
      namespace: "$app:my_cart_checkout_shop_namespace"
      key: "my_cart_checkout_shop_key"
    ) {
      value
    }
  }
}
 

As mentioned in the doc that variables need to be declared into the toml file is already being declared

  [extensions.input.variables]
   namespace: "$app:my_cart_checkout_shop_namespace"
   key: "my_cart_checkout_shop_key"
 
 
at the javascript side , metafiled is created like this

let rules = { };
rules.selectedProductTags = ["Accessory"];
rules.selectedCollectionIds = ["Home"];

await admin.rest.put({
    path: `${"metafields/" + metafieldId + ".json"}`,
    data: JSON.stringify({
      metafield: {
        id: metafieldId,
        value: JSON.stringify(rules),
        type: "json",
      },
    }),
  });
Replies 0 (0)