Hi,
I am fairly new to Shopify App development. I am attempting to create an app that injects custom labels on a collection page. I am aware there are apps that already do this, however, I am wanting to do this for learning purposes.
I have spent the last few days trying to come up with the best solution on how to achieve this functionality. My goal is to create an app that is:
- Theme agnostic
- Allows merchants to inject labels on the collection page at various positions within the product item’s card (i.e above title, above the price, etc)
Now, I’ve been playing around and have managed to achieve this somewhat, however, along the way I discovered a few problems that I would love some feedback on.
The collection grid within the theme editor is it’s own block. Therefore you can’t use app blocks to inject labels WITHIN the collection grid, only above and below the the entire collection grid. So, I resorted to using an app embed block that uses JS to scan the page for the correct injection point… Which lead to my next issue.
How would you go about making this app theme agnostic without knowing a themes structure? Currently, I am identifying collection items using common patterns, but these patterns can vary drastically from theme to theme and would be impossible to nail every one. I want to try and avoid just having a known list of theme layout patterns and create something that can figure this out on its own.
So, my next idea was to figure out a theme’s collection grid pattern in the admin panel and store that somewhere. I figured this may be easier, as you’d be able to have access to more of the themes information. Then I could get my front end script to retrieve the exact pattern and then search for it on the page. But that lead to more road blocks that I am struggling to get my head around.
I have seen apps do this before so I know it’s possible. I am just looking for some advice or other ideas that I may have overlooked.
I wasn’t sure if this is the correct spot to write this post so feel free to move if necessary.
TIA