Liquid, JavaScript, themes, sales channels
Hi,
When my app is installed, i am creating a snippet using the asset api. And rendering that snippet in the theme.liquid file (by using the asset api to update the theme.liquid file).
My problem is when the app is uninstalled, i lose access and i cannot remove the snippet i had added. So, is there any way to stop a snippet from rendering when my app is uninstalled?
I have noticed that when i uninstall some apps, this message is shown in the DOM
<!-- "snippets/example.liquid" was not rendered, the associated app was uninstalled -->
But i wasn't able to replicate the above behaviour with my app. Even after i uninstalled my app, the snippet was still getting rendered. I am not sure if that is because i was testing in a development store. Can anyone please tell me how to replicate the above behaviour or is there any other way to not render a snippet when app is uninstalled?
Thanks
{% if shop.apps['your-app-handle'] %}
<!-- Your snippet code here -->
{% endif %}
In this example, the shop.apps object is used to check if your app is installed on the current store. If it is, the snippet code will be rendered. If not, the snippet code will be skipped and will not be rendered on the page.
It is important to note that the your-app-handle value in the example code should be replaced with the actual handle of your app.
Hey @NiccosMedia, I tried your solution. It doesn't seem to work. My snippet is not getting rendered even if the app is installed.
There doesn't seem to be a property named "apps" on the shop object. It is not mentioned in the documentation as well: https://shopify.dev/api/liquid/objects/shop
Can you please share any documentation that you referred for the above solution.
If there is any other way to stop the snippet from rendering when the app is uninstalled, please do let me know, it would be of great help
User | RANK |
---|---|
33 | |
25 | |
17 | |
9 | |
9 |
Photo by Marco Verch Sales channels on Shopify are various platforms where you can sell...
By Ollie May 25, 2023Summary of EventsBeginning in January of 2023, some merchants reported seeing a large amo...
By Trevor May 15, 2023With 2-Factor Authentication being required to use Shopify Payments, we’re here to help yo...
By Imogen Apr 26, 2023