Adding custom html elements via API from APP

evgenshe
New Member
4 0 0

Hi, 
I'm trying to add custom HTML to the product page via API. Working good
but I've faced with the problem that themes are different and I can't know all positions of elements 

for example, I need to add HTML right after the product title on the product page and in the catalog product listing 

Screenshot 2021-03-14 at 12.43.10.png
Screenshot 2021-03-14 at 12.43.37.png

and I'm wondering if there some rules that can help me define where are these elements? 
maybe some class that will be there in all themes
I'm trying to find some regularity that will help me to find these elements on all themes
and I can parse HTML and insert it there 

0 Likes
parthgoyani
New Member
1 0 0

Hello evgenshe,

I hope you are well. You can use script tag API for that. (https://shopify.dev/docs/admin-api/rest/reference/online-store/scripttag)

You can follow the below steps:

  1. Decide a ID or Class name e.g. #customhtmlinjector or .customhtmlinjector 
  2. Specify that HTML tag with id/class in installation guide 

 

<div class="customhtmlinjector"></div>
or
<div id="customhtmlinjector"></div>

 

  • let your app customer/store owner place/put that tag where they want
  • Now you got a targeted element to inject your HTML elements using script tag  This is the only way.

This is the Only way I found till now.

0 Likes