Prefered way to modify theme with an app

Highlighted
Tourist
15 0 1

Hi,

After reading https://shopify.dev/tutorials/modify-the-online-store-channel, I see there are several ways to modify a shopify theme with an app. But whats the preferred way to do it in 2020 ?

Some details: I want to modify the cart page to add a progress bar, based on data stored in my app database.

 

Thanks !

0 Likes
Highlighted
Shopify Partner
1777 211 370

In 2020 it would be App Sections, but app sections are not yet supported on all pages, I believe they only work on product pages. So for your specific case you are left with two options. You can either use ScriptTags - https://shopify.dev/docs/admin-api/rest/reference/online-store/scripttag - you can register your JavaScript library and Shopify would load it, or use Theme API - https://shopify.dev/docs/admin-api/rest/reference/online-store/theme - and inject any code into the theme's files.

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
0 Likes
Highlighted
Tourist
15 0 1

Thank you for your response.

Is there a cleanup mechanism when using the theme/asset API ? I mean, if I modify a theme file, and then if the customer delete my app, will the modified theme files remain ? Because it could break things

0 Likes
Highlighted
Shopify Partner
1777 211 370

Unfortunately, there are no cleanup hooks, and that was the reason for Shopify to start working on App Sections. If you have concerns re left overs, you can go ahead with ScriptTags. ScriptTags are removed from the store once the app is uninstalled, leaving no traces.

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
0 Likes