Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to insert custom HTML in theme via custom Shopify App?

Tags:

shopify

I want to include custom HTML in shopify theme whenever user install / enable my APP in their store. Can anyone suggest me that how to do that ?

like image 961
Rahil Avatar asked Mar 24 '14 13:03

Rahil


People also ask

Can you use custom HTML Shopify?

Add custom HTML or LiquidThese settings let you safely add custom code to your online store without editing your theme's code directly, which helps to ensure that your theme is eligible for automatic upgrades.


1 Answers

Using the Asset API you can add or update assets, for example your custom HTML. An asset belongs to a theme, so probably you also need the Theme API, which gives you access to the installed theme(s) and it's role(s). You shouldn't update existing assets which don't belong to your own App.

If you only want to add a JavaScript to the store, you might want to use a ScriptTag.

A third option is to use application proxies. Application proxies will forward web requests to your application. Your application returns custom HTML (or Liquid), which will be returned to the visitor. This way you extend the store with for example an image gallery.

Keep in mind assets won't be removed when the store uninstalls your App. Also after uninstall you don't have access to your assets anymore. A ScriptTag will be removed when the store uninstalls your App. For an application proxy you can implement an access mechanism yourself and deny access when the store uninstalls your App.

like image 81
hjblok Avatar answered Sep 18 '22 12:09

hjblok