Hello, I’m new to app development, and I am stuck with this issue. So I created a theme extension and I have a block that I want to make conditional (it will be available in the theme editor app block list only when the merchant enables it from the app UI). According to the documentation, I should add available_if
attribute to my schema, so I did this:
{% schema %}
{
"name": "name",
"target": "section",
"available_if": "{{ app.metafields.namespace.test }}",
"settings": [
{
"type": "paragraph",
"content": "Edit settings in widget settings inside app"
}
]
}
{% endschema %}
In my app UI I set metafileds in the following way:
const UPDATE_METAFIELD_MUTATION = `
mutation metafieldsSet($metafields: [MetafieldsSetInput!]!) {
metafieldsSet(metafields: $metafields) {
metafields {
key
value
}
userErrors {
field
message
}
}
}
`;
await admin.graphql(UPDATE_METAFIELD_MUTATION, {
variables: {
metafields: [
{
namespace: "namespace",
key: `test`,
value: "true",
type: "boolean",
ownerId: '...',
},
],
},
});
This works, I can see metafields created this way in the app UI, but the block is not on the list.
Also, I tried a different approach with creating metafields with CreateMetafieldDefinition
with access { storefront } and then setting the value to true, but this does not work either.
Hopefully, this makes sense, any help is appreciated.