Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

What is the best way to modify a user's theme current?

Solved

What is the best way to modify a user's theme current?

dachan
Visitor
1 0 0

Hi, I am trying to build an app that will modify the layout of a user's existing theme.

Functionally I believe it has a lot in common with the the free shipping bar apps as I basically need to know when there is something in their shopping cart and also know how much their current cart total is.

Looking through the documentation, there seems to be 2 alternatives:

1) I can use the Theme API to get the current theme and the Asset APIs to alter it. If I do this, how do I insert a piece of code to the existing theme? do I actually have to make a copy of the liquid file and then manually inject the extra html code? there doesn't seem to be a way to target a specific id or class and insert my html through the asset API.

2) I can use a script tag + webhooks to get cart data. One of the negatives to this solution is the webhooks have a bit of a delay.

Is there one that is considered best practice?

Thanks in advance!

 

Accepted Solution (1)

Paul_vd_Dool
Shopify Partner
112 6 99

This is an accepted solution.

Hi Dachan,

I've found this article to be very insightful into the different methods of altering the storefront with an app. It also discusses the downsides of the different methods.
Maybe you find it helpful as well.

https://www.shopify.com/partners/blog/add-code-from-your-app

Doppelganger - Managing duplicate user accounts

View solution in original post

Replies 3 (3)

Paul_vd_Dool
Shopify Partner
112 6 99

This is an accepted solution.

Hi Dachan,

I've found this article to be very insightful into the different methods of altering the storefront with an app. It also discusses the downsides of the different methods.
Maybe you find it helpful as well.

https://www.shopify.com/partners/blog/add-code-from-your-app

Doppelganger - Managing duplicate user accounts
ryanhovr
Visitor
1 0 0

Hi Paul, the link leads to a 404, do you have another link? My company's app would inject some html/js onto a users site.

Paul_vd_Dool
Shopify Partner
112 6 99

Hi Ryan,

It seems Shopify has removed that blog post. I guess because they would prefer you to build theme app extensions.
https://shopify.dev/apps/online-store/theme-app-extensions

Doppelganger - Managing duplicate user accounts