Understand theme app extensions

Hello,

Can someone please explain what I’m seeing here in a customers store?

They’ve installed our app, and the theme app extension is available to insert, however it only works when added to the “Apps” section as per the screenshot. It does not work in the “Product” section. When inserted to the “Product” section, the extension does not output correctly on the frontend of the store.

In all our testing and in other store installs, it works when customers insert into say a “product information” section. I haven’t seen this product section before.

For reference this is in the “default product” template.

Thanks,

J

1 Like

Hey James,

Thanks for reaching out about theme app extensions!

Can you provide more information on how it doesn’t render correctly?
Is it not rendering at all or is it returning an error?

If you’re able to add the theme app extension via the theme editor, then the section schema is set up correctly e.g. :

{% schema %}
{
  "name": "Product",
  "blocks": [
    {
      "type": "@theme"
    },
    {
      "type": "@app"
    }
  ],
  "settings": []
}
{% endschema %}

But the app block is not rendering at all, then likely they are missing either of the folllowing:

A) Theme has a /blocks folder and supports theme blocks:

    {% content_for 'blocks' %}

B) Theme doesn’t have a /blocks folder and doesn’t support theme blocks:

{% for block in section.blocks %}
  {% if block.type == '@app' %}
    {% render block %}
  {% endif %}
{% endfor %}

Hopefully that helps! Let me know if you have any questions :slight_smile:

Thanks for responding!

Turns out the clients theme was missing the render block inside their legacy product section file i.e.

{% for block in section.blocks %}                 
   {% case block.type %} 
      {% when '@app' %}      
         {% render block %} // this was missing
      
      {% when 'sku' %}
         // -------------

Nice find! Glad you were able to resolve it :clap: