Ad

Is It Possible To Add A Custom Input And Call 3rd Party API With The ScriptTag?

- 1 answer

The Shopify documentation on the ScriptTag is really vague. For example, it says that the following endpoint will create a new script tag:

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

But what should I put into that src js file? Is it possible to add a custom input into a chosen online store page? If so, how? I couldn't find any documentation or even a post about this.

Ad

Answer

A script tag is loaded by Shopify and executes after onload. What can you do with that? Well, as an App developer, you may very well want some Javascript code to run, without you having to have the merchant install that code. Merchants are often not technical.

So you write Javascript in your fancy.js file that adds value to the merchant. Your JS could render a new DOM element like an input and deal with changes to it. Sure. Why not. Dare to dream. Dream big!

Ad
source: stackoverflow.com
Ad