What's your biggest current challenge? Have your say in Community Polls along the right column.

Can't access setting values in a theme app embed

Solved

Can't access setting values in a theme app embed

siacodes
Shopify Partner
2 1 0

Hi, I'm trying to add settings to my theme app embed and access them, but no matter what I prepend `settings` with (nothing, block, app, shop), I get not found in the browser:

 

In extensions > test-extension > blocks > file.liquid:

 

 

<script>
  console.log('app embed loaded!')
  console.log(`popcorn from settings: ${[all the examples above].settings.popcorn}`)
</script>

{% schema %}
{
  "name": "Script Embed",
  "target": "head",
  "settings": [
    {
    "type": "number",
    "id": "popcorn",
    "label": "name of your popcorn"
    }
  ]
}
{% endschema %}

 

Accepted Solution (1)

siacodes
Shopify Partner
2 1 0

This is an accepted solution.

Ugh I was dumb and forgot to wrap it in extra curly braces for Liquid. Works now. Feel free to delete this whole question. I couldn't figure out how so dropping in the answer instead:

 

```

const apiKey = "{{block.settings.popcorn}}"
console.log(`app ID from settings: ${apiKey}`)
```

 

View solution in original post

Reply 1 (1)

siacodes
Shopify Partner
2 1 0

This is an accepted solution.

Ugh I was dumb and forgot to wrap it in extra curly braces for Liquid. Works now. Feel free to delete this whole question. I couldn't figure out how so dropping in the answer instead:

 

```

const apiKey = "{{block.settings.popcorn}}"
console.log(`app ID from settings: ${apiKey}`)
```