How to add script to the front side of the shopify app

强颜欢笑 提交于 2020-03-04 04:29:46

问题


As i am new to shopify app i created an app and installed over a store with script tag having read and write permission . How can i dynamically add the javascript to the front side of shopify app.


回答1:


Use the Script Tag API to create the javascript you want to load dynamically.

# POST /admin/script_tags.json

{
  "script_tag": {
    "event": "onload",
    "src": "https://djavaskripped.org/fancy.js"
  }
}

Documentation: Link




回答2:


When your App is installed in a Shop, the merchant usually gets two dialogs to confirm. One is if you are asking for a billing charge. The other is for the scopes access to their shop. Assuming they approve both, you will get an oAuth token allowing you to read/write ScriptTag endpoint.

So when you get that oAuth token, you save it along with the shop name, and that is finally when you can POST your script tag payload in the store.



来源:https://stackoverflow.com/questions/54453671/how-to-add-script-to-the-front-side-of-the-shopify-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!