I'm looking to inject some liquid code consistently across all of my users' stores. The problem is that each store has different themes, meaning that there is no real consistent structure from the stores to inject an element based upon.
What are some recommended solutions for this? I'm looking to inject a piece of code into the product page template specifically.
Thank you. Any advice is greatly appreciated.
You can't "inject" liquid with a naive approach to an arbitrary line in an arbitrary template for an arbitrary theme.
Liquid isn't a fully formed language with introspection tools and there are just too many variations in themes, even within shopify store themes.
There is no standard nor even reliable conventions for reliably telling themes apart quickly and efficiently.
A massive painpoint is you cannot confidently rely on the theme title, info in config files, or name info returned by the api to establish which theme the user is actually using. Even to tell if a theme is non-sectioned or sectioned is pretty much a separate thing.
So any automatic "injection" of template code into a template language like liquid needs static analysis over the entire theme files and building up theme fingerprints which would be alot of work for app developers. And even then that would always hit edge cases like when two themes get kitbashed together.
This is why you'll see most apps that need to "inject" either some mix of the following:
Hyperbole and WIP opinion: In the future possibly this might ⚠ be a saner process with the new online store design experience having a different way for apps to interact with section themes with "app sections"|"app extensions".
(Timestamps - "App Sections" 6:27 product reviews widget , 18:10 app devs & themes, 31:42 question -app section category on app store? ,33:38 question - app installs mess up themes will app sections help with clean code during install?)
|4 hours ago|
|5 hours ago|
|5 hours ago|
|6 hours ago|
|7 hours ago|