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 approach for updating/replacing existing section using App?

Solved

What is approach for updating/replacing existing section using App?

VitalyGryaznov
Shopify Partner
2 0 1

I'm building an app that should update content of the registration page (/account/register).

As far as I understood 'App blocks' and 'App embeds' can't be used for this. Documentation says that App could "inject code directly into your theme's code to add functionality", but I didn't manage to find any documentation or tutorial for that case. All I found is related to 'App blocks'. In my case, I don't want to add a block I want to change or replace an existing section.

Any approach suggestions or links to related tutorials are highly appreciated 😃

Accepted Solution (1)

PaulNewton
Shopify Partner
7721 678 1620

This is an accepted solution.

You need to uses the assets api to modify theme assets directly.

Backend

Before replacing ALWAYS either be making a backup of the theme with some way for merchant restoration, or duplicate the section with OLD|BACKUP etc in the name; and or or make your own section name i.e. main-section-myappname.liquid and update references in other files.

When adding a new asset make sure either in the name or top of file to note where the file came from.

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

Frontend

For client-side replace of a section use the section rendering api.

https://shopify.dev/api/section-rendering 

 

 

 

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org


View solution in original post

Replies 2 (2)

PaulNewton
Shopify Partner
7721 678 1620

This is an accepted solution.

You need to uses the assets api to modify theme assets directly.

Backend

Before replacing ALWAYS either be making a backup of the theme with some way for merchant restoration, or duplicate the section with OLD|BACKUP etc in the name; and or or make your own section name i.e. main-section-myappname.liquid and update references in other files.

When adding a new asset make sure either in the name or top of file to note where the file came from.

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

Frontend

For client-side replace of a section use the section rendering api.

https://shopify.dev/api/section-rendering 

 

 

 

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org


VitalyGryaznov
Shopify Partner
2 0 1

Thank you a lot for such a detailed and helpful answer!