App Block getting excluded on page render

Hey all,

A merchant has my app installed, and they’ve added my app block to their default product page template. It’s visible on the product page within the Theme Customizer.

However, when the product page is viewed on the website, the app block isn’t there. The container is completely missing from the markup.

When I look at product.json, the app block is definitely there - it’s one of 4 blocks, the other 3 being standard blocks from the theme (which is Dawn).

I’ve done a whole bunch of troubleshooting in main-product.liquid, to output the blocks to screen. For example, looping the blocks and outputting name or id. Outputting a count of section.blocks gives 3 rather than 4.

I’m putting this code at the very top of main-product.liquid, well before the switch function that outputs blocks differently based on their type. The switch has an allowance for when type is @app - however this doesn’t seem too relevant as the block seems to be missing well before this code is reached.

The theme is the current/published one on the store, and there’s only one product page template (default product). All products are set to use this template.

The merchant says it’s been working for some time on the live site but disappeared as of a few days ago. This doesn’t align with any new releases of the app.

Are there any other reasons Shopify would be excluding the app block from the list of section.blocks when rendering the product page?

No other merchants have reported a similar issue. There are hundreds of merchants with the app block being used on their product pages.

Any help would be much appreciated!

Thanks,
Gunner

Is your app block visible in the Shopify customizer, like, is it actually rendering? If yes, then please double-check if the market is correct. Sometimes stores have multiple markets, and it’s possible the customizer is showing one market while the live site defaults to another.

Also, some themes have optimizer apps installed that randomly remove app blocks for performance reasons. Definitely worth checking if the merchant has anything like that installed.

From what you described, I don’t see any other obvious reason for the block being excluded. I’ve faced similar issues before and 90% of the time it was either the market mismatch or an optimizer app causing the block to disappear.

One last thing, double check the rendering code in the theme and make sure app blocks are actually considered in the loop logic. Some customizations accidentally skip @app blocks.

Hope this helps!

Thanks for responding @Gulam_Hussain_Quinn

Yes the app block definitely renders in the theme customizer. No issues there at all.

App block is definitely in the loop logic:


However as mentioned, the app block doesn’t seem to be part of section.blocks, so the problem is higher up the chain that this.

I don’t have permissions to view Markets on the store. There’s no indication of multiple markets being set up but maybe that’s due to my permissions. I’ll contact the merchant about it though.

There’s only a small number of apps on the store and none seem to be performance optimizers.

No idea then what’s going on, please do update here once you find the root cause. Interesting issue

Yeah, super weird.

I put this code into main-product.liquid

{{ section.blocks.size }} blocks in this section
{% for block in section.blocks %}
  - {{ block.type }} / {{ block.id }}<br>
{% endfor %}

Then when I view the product in the theme customizer, I see:

4 blocks in this section
- title / title
- description / description_Uz74Dr
- price / price
- @app / APUK3VSZJaERLbk82d__my_app_widget_name_BTEx7Q

When I go to the product page on the live site, I see:

3 blocks in this section
- title / title
- description / description_Uz74Dr
- price / price

Ok so I think it’s definitely related to markets. But still seeing some odd behaviour.

So first off, I installed a fresh copy of Dawn, added the app block. Everything is fine.

Installed a fresh copy of Craft (another free theme), added the app block. Everything is fine.

I compared the theme files between the live theme (based on Dawn) and the fresh copy of Dawn. I discovered the live theme had this file: sections/header-group.context.nl.json

This was the contents:

{
  "parent": "header-group.json",
  "context": {
    "market": "nl"
  },
  "sections": {
    "announcement-bar": {
      "settings": {},
      "blocks": {},
      "block_order": []
    }
  }
}

When I added this file to the fresh copy of Dawn, I saw the same behaviour as the live theme, the app block disappeared.

So then, I went to the live theme and modified the file. I updated it to:

{
  "parent": "header-group.json",
  "context": {
    "market": "nl"
  }
}

This fixed it! The live theme started showing the app block.

Just to make sure, I reverted the file to it’s original contents. The live theme stopped showing the app block.

The problem now is that now I can’t fix it again. Removing the sections from the file again does not fix it.

I even went back to the fresh copy of Dawn, edited and also tried deleting the file, and it too stayed broken.

What is going on and how can I repair this theme? It’s feeling like the best option is to start with a fresh Dawn again and build up the theme from scratch to where the current theme is at.

Thanks in advance

Hey @gunner :waving_hand:

Is the merchant running any additional customization implementations in Liquid or through theme extensions? That would usually be the first thing we’d recommend checking like @Gulam_Hussain_Quinn mentioned there.

Usually those header-group files are been created as part of a migration to section groups from static sections, so I’m wondering if there are additional scripts running that might affect your app block there: Migrate static sections to section groups

If you can confirm that there aren’t any other extensions/scripts that might be affecting the theme, just ping me here and we can keep digging into this over DM (since we’ll likely be dealing with some merchant-specific data). Let me know if I can help out further :slight_smile:

Hey @Alan_G

It’s a pretty new store and when I compare the full theme files against a fresh copy of Dawn there isn’t a huge number of differences. I’d be surprised if there was any migration from static sections.

I’ll DM you now with more details!

Thanks