Difference between revisions of "API ScriptTag"

From Spiffy Stores Knowledge Base

Line 33: Line 33:
 
{| class="wikitable" style="width: 100%"
 
{| class="wikitable" style="width: 100%"
 
|style="width: 30%"|created_at
 
|style="width: 30%"|created_at
|"created_at": "2012-08-24T14:01:47-04:00"<br>The date and time when the ScriptTag was created. The API returns this value in ISO 8601 format.
+
|<pre>"created_at": "2012-08-24T14:01:47-04:00"</pre><br>The date and time when the ScriptTag was created. The API returns this value in ISO 8601 format.
 
|-
 
|-
 
|event
 
|event
|"event": "onload"<br>DOM event which triggers the loading of the script. Valid values are: "onload."
+
|<pre>"event": "onload"</pre><br>DOM event which triggers the loading of the script. Valid values are: "onload."
 
|-
 
|-
 
|id
 
|id
|"id": 596726825<br>The unique numeric identifier for the ScriptTag.
+
|<pre>"id": 596726825</pre><br>The unique numeric identifier for the ScriptTag.
 
|-
 
|-
 
|src
 
|src
|"src": "https://js-aplenty.com/foo.js"<br>Specifies the location of the ScriptTag.
+
|<pre>"src": "https://js-aplenty.com/foo.js"</pre><br>Specifies the location of the ScriptTag.
 
|-
 
|-
 
|display_scope
 
|display_scope
|"display_scope": "online_store"<br>Specifies where the file should be included. "online_store" means only web storefront, "order_status" means only the order status page, while "all" means both.
+
|<pre>"display_scope": "online_store"</pre><br>Specifies where the file should be included. "online_store" means only web storefront, "order_status" means only the order status page, while "all" means both.
 
|-
 
|-
 
|updated_at
 
|updated_at
|"updated_at": "2012-08-24T14:01:47-04:00"<br>The date and time when the ScriptTag was last updated. The API returns this value in ISO 8601 format.
+
|<pre>"updated_at": "2012-08-24T14:01:47-04:00"</pre><br>The date and time when the ScriptTag was last updated. The API returns this value in ISO 8601 format.
 
|}
 
|}
  

Revision as of 09:56, 16 May 2017

The ScriptTag resource represents remote JavaScripts which are loaded into the pages of a store's shopfront and in the order status page of checkout. This makes it easy to add functionality to those pages without touching any theme templates.

A script tag has the following attributes:

  • src: The URL of the remote script.
  • event: The DOM event which triggers the loading of the script. Currently, "onload" is the only supported event.
  • display_scope: Tell Spiffy Stores where to include the script; "online_store", "order_status" or "all". Default to "all".


ScriptTags are scoped to the app that created them. When an app is uninstalled from a shop, all of the script tags which it created are automatically removed along with it.


What you can do with ScriptTag

The Spiffy Stores API lets you do the following with the ScriptTag resource. More detailed versions of these general actions may be available:

  • GET /admin/script_tags.json
    Receive a list of all ScriptTags
  • GET /admin/script_tags/count.json
    Receive a count of all ScriptTags
  • GET /admin/script_tags/#{id}.json
    Receive a single ScriptTag
  • POST /admin/script_tags.json
    Create a new ScriptTag
  • PUT /admin/script_tags/#{id}.json
    Modify an existing ScriptTag
  • DELETE /admin/script_tags/#{id}.json
    Remove a ScriptTag from the database


ScriptTag properties

created_at
"created_at": "2012-08-24T14:01:47-04:00"

The date and time when the ScriptTag was created. The API returns this value in ISO 8601 format.
event
"event": "onload"

DOM event which triggers the loading of the script. Valid values are: "onload."
id
"id": 596726825

The unique numeric identifier for the ScriptTag.
src
"src": "https://js-aplenty.com/foo.js"

Specifies the location of the ScriptTag.
display_scope
"display_scope": "online_store"

Specifies where the file should be included. "online_store" means only web storefront, "order_status" means only the order status page, while "all" means both.
updated_at
"updated_at": "2012-08-24T14:01:47-04:00"

The date and time when the ScriptTag was last updated. The API returns this value in ISO 8601 format.




Further Reference