I am developing a discount app and looking to insert “Asset” and “Script” into merchant’s product page which conditionally shows that this product is in discount bundle with another product X.
I was following this tutorial: https://www.youtube.com/watch?v=0dp0Lr9Y_P4&ab_channel=ShopifyDevs And the steps I figured out were necessary were:
-
Get /admin/themes where the theme role is main
-
Get /admin/themes/{themeId}/assets with query asset[key]:layout/theme.liquid
-
Find symbols in the theme body section ‘header’ and insert programatically:
{% if content_for_header contains 'script-tags.ngrok.io' &}
{% render 'script-tag-app' %}
{% endif %}
- Create a script through a POST request:
{"script_tag": {"event": "onload","src": "https://scripts-tags.ngrok.io/script}}
- Create a snippet through a POST request:
{"asset": {"key": "snippets/script-tag-app.liquid","value": "Some injected text
"}}
Do I understand all of this correctly? I am struggling with 2 and 3 steps.