How to update custom Theme Sections as an app developer

We have published a Shopify app and along with it, a Shopify 2.0 theme app extension so that merchants can easily add our app to a section of their web pages.

We want to be able to support merchants on Shopify 1.0 themes as well, which entails having the merchant add custom code in the form of a Liquid Section in their theme customizer.

With our 2.0 app extension, we can publish new versions when we make updates to our code. But with the 1.0 approach, we don’t have an easy way to update the code that was originally added to the merchant’s theme.

How can we automatically update the code that is added to a merchant’s 1.0 theme

Use the assets api to add or replace theme files.

If your going to implement automatic updates you may as well implement automatic install.

Having merchants add the code for a section to a template is incredibly error prone.

Always generate a backup of the file and or the entire vintage theme.

And keep in in the section behavior for JSON templates and liquid templates.

REST admin api https://shopify.dev/api/admin-rest/2022-10/resources/asset

Graphql api discussion https://community.shopify.com/c/technical-q-a/accessing-asset-files-through-graphql-api/td-p/1539893

See assets api and scripttag api

https://shopify.dev/apps/online-store/other-integration-methods

Also see section rendering api for dynamic client-side behavior instead of insitu template rendering https://shopify.dev/docs/themes/sections/section-rendering-api

1 Like

This is super helpful input, thank you for sharing. I’ve been spending time deep diving into both the Assets API and the ScriptTag API. I believe both directions will work for this.

The ScriptTags seem to be the most automated since we’re never touching the theme code and there is no need for manual intervention for the merchant. Are there any downsides that I should be aware of if using the ScriptTag over the Assets API?

Actually, I now realized that with the ScriptTag, there is no way to accurately inject HTML code into the theme at a specific section that is defined by the merchant.

Looks like the Asset API is going to be our best bet. We can do this automatically when the merchant installs our app, but we would just be blindly adding the asset to their Theme. Do you know what the best way would be for the merchant to be able to specify which section of their theme they would want the asset installed?