I’m implementing a Select Template Grid feature.
When creating a Product Offer Rule, six different grid options will be displayed. The merchant selects one grid, and that selected grid should appear on the Product Page where our app embed block is used.
Now, my question is about how to handle the Grid Setting Configuration:
Option 1: Save settings inside the Theme Extension Schema
{% schema %}
{
“name”: “Conditional App block”,
“target”: “section”,
“stylesheet”: “app.css”,
“javascript”: “app.js”,
“available_if”: “{{ app.metafields.conditional.block1 }}”,
“settings”: [
{
“label”: “Colour”,
“id”: “colour”,
“type”: “color”,
“default”: “#000000”
}
]
}
{% endschema %}
In this approach, configuration is stored within the theme schema of the extension.
Option 2: Save settings inside App Metafields (Application Data)
mutation CreateAppDataMetafield($metafieldsSetInput: [MetafieldsSetInput!]!) {
metafieldsSet(metafields: $metafieldsSetInput) {
metafields {
id
namespace
key
}
userErrors {
field
message
}
}
}
{
“metafieldsSetInput”: [
{
“namespace”: “secret_keys”,
“key”: “api_key”,
“type”: “single_line_text_field”,
“value”: “aS1hbS1hLXNlY3JldC1hcGkta2V5Cg==”,
“ownerId”: “gid://shopify/AppInstallation/3”
}
]
}
In this approach, we store configuration values (like grid selection) in App Installation Metafields using a custom namespace and key.
My Question
Since we’re planning to develop a new Shopify app, which is the best approach to save app configuration?
-
Theme Schema (Theme Extension)
-
Application Data (App Metafields)
Or should we use App Metafields with namespace and key for configuration instead of the theme schema?