I have an app that has its own metafields assigned to the products. They are read-only fields, as they only need to be used by one product. I am creating a checkout UI extension that will add a banner with that product info to allow a customer to add it to their cart if it doesn’t already exist. Very similar to this example. I am having a difficult time querying that product by the custom metafields set up by my app. Here is my current query:
`query ($query: String!) {
products(first: 1, query: $query) {
nodes {
id
title
images(first: 1) {
nodes {
url
}
}
variants(first: 1) {
nodes {
id
price {
amount
}
}
}
metafield(namespace: "$app:protection_product", key: "is-protection-product") {
value
}
}
}
}`,
{
variables: {
query: "metafields.$app:protection_product.is-protection-product:true"
}
}
I’m aware that the “$app:” in the query essentially stops the query, thinking everything after the colon is the value I’m looking for, which obviously doesn’t work. I’ve also manually put in the app namespace (app–12456–), but still the query is not working. The field is a true/false field, I just need to query the product with the “true” value. Regardless of how I mess with it, it is just returning the first product in my product list, which is not the correct product.
I’ve gone and added the metafield to my extension’s TOML file, and messed around with the useAppMetafields functionality, but from my understanding that’s only for the products that are present in checkout. I am looking to show a product that isn’t presently in the checkout/cart.
Any assistance on this would be much appreciated.