Automatically create button when application is installed on store

Solved
Highlighted
Excursionist
11 1 0

Hi,

It is my first experience with Shopify app development. I am creating a public embedded app.

 

This is how far its okay:
A "test merchant" can successfully install it and see their products in embedded app. I also have edited theme of merchant's store manually and created a button on products page which on click navigate/redirect customer to some other website to perform action which in return give him discount code.

 

What i do not understand:

Now I want to build functionality in my public app so that any merchant who installs app on store, can add that button to their theme with a single click or a button is automatically created on their products page.

 

I am not even sure if this is possible or not. I tried to find stuff related this in docs but am bit lost. Would be great if you could point me what docs should I read or how I can achieve this. Any code sample would greatly be appreciated.

 

Thank you,

Ahmed

 

0 Likes
Highlighted

Success.

Shopify Staff
Shopify Staff
905 120 129

Hey @ahmed23,

 

Consider using a ScriptTag to append elements to the product page. Keep in mind each theme is different, so this can get awkward.

0 Likes
Highlighted
Excursionist
11 1 0

Thank you for reply.

 

Is there any alternative so that I don't have to worry about theme design?

0 Likes
Highlighted
Shopify Staff
Shopify Staff
905 120 129

Some alternatives:

- Use a modal/position:fixed, so you don't need to worry about placement, but that wont be a great UX.
- Provide the merchant with installation instructions (so they can position the button).

- Offer to install the button for the merchant (so you can position the button).

0 Likes
Highlighted
Excursionist
11 1 0

So I managed to add scripttag to my app and script in it runs whenever merchant installs/visits app. But I actually want that script to run when a customer visits store's product page(script actually creates a button). How this can be achieved?

0 Likes
Highlighted
Shopify Staff
Shopify Staff
905 120 129

One approach is to look for `/products/` in the URL.

0 Likes
Highlighted
Excursionist
11 1 0

thank you,

0 Likes