Theme Script


Theme scripts allows You to easly add additional scripts to storefront theme and also to order status page. Each script is associated with application which install it. When an applicaiton will be uninstalled, then all scripts associated with this application will be removed.

Theme Script properties

created_at "created_at": "2012-09-18 14:20:55"

Date and time when a script was created in format YYYY-MM-DD HH:ii:ss.
event_type "event_type": "onload"

Available option right now is only "onload". Scripts will be loaded onload event at the end of the page
id "id": 74

Unique numeric product identifier. Each id is unique only in the store. Across Shoplo platform product identifier can be repeated.
scope "scope": "all"

The page or pages on which script should be included. Valid values are:
  • all - script will be display on each page of a store
  • store - script will be display on each page of a store except order status page (Thank You Page)
  • order_status - script will be display on order status page (Thank You Page)
src "src": "https://www.shoplo.com/all.js"

The URL of the remote script.
updated_at "updated_at": "2012-09-18 14:20:55"

Date and time when a script was updated in format YYYY-MM-DD HH:ii:ss.


Receive a list of all scripts

Query parameters:
  • limit - number of returned scripts (default: 50)
  • page - currently displayed page (default: 1)
  • created_at_min - counts scripts, which creation date was later than specified (format: 2011-06-19 13:18:50)
  • created_at_max - counts scripts, which creation date was earlier than specified (format: 2011-06-19 13:18:50)
  • updated_at_min - counts scripts, which modification date was later than specified (format: 2011-06-19 13:18:50)
  • updated_at_max - counts scripts, which modification date was earlier than specified (format: 2011-06-19 13:18:50)
GET /services/theme_scripts

Returns all theme scripts

HTTP/1.1 200 OK
{
	"theme_scripts": [
        {
            "id": "1",
            "event_type": "onload",
            "src": "https://www.shoplo.com/all.js",
            "scope": "all",
            "created_at": "2018-07-23 19:03:08",
            "updated_at": "2018-07-23 19:03:08"
        },
        {
            "id": "6",
            "event_type": "onload",
            "src": "https://www.shoplo.pl/example.js",
            "scope": "store",
            "created_at": "2018-07-23 19:04:40",
            "updated_at": "2018-07-23 19:04:40"
        },
        {
            "id": "7",
            "event_type": "onload",
            "src": "https://www.shoplo.pl/order_status.js",
            "scope": "order_status",
            "created_at": "2018-07-23 19:05:08",
            "updated_at": "2018-07-23 19:05:08"
        }
    ],
}

Receive a count of all scripts

Query parameters:
  • created_at_min - counts scripts, which creation date was later than specified (format: 2011-06-19 13:18:50)
  • created_at_max - counts scripts, which creation date was earlier than specified (format: 2011-06-19 13:18:50)
  • updated_at_min - counts scripts, which modification date was later than specified (format: 2011-06-19 13:18:50)
  • updated_at_max - counts scripts, which modification date was earlier than specified (format: 2011-06-19 13:18:50)
GET /services/products/count

Receive a count of all Products

HTTP/1.1 200 OK
{
	"count": 8920
}

Create a new Theme Script

POST /services/theme_scripts

You can create a new theme script and decide on which page should it be loaded.

Request
{
	"theme_script": {
		"event_type": "onload",
                "src": "https://www.shoplo.pl/track_user.js",
                "scope": "all"
	}
}
Response
HTTP/1.1 200 OK
{
	"theme_script": {
            "id": "7",
            "event_type": "onload",
            "src": "https://www.shoplo.pl/track_user.js",
            "scope": "all",
            "created_at": "2018-07-23 19:05:08",
            "updated_at": "2018-07-23 19:05:08"
        }
}

Update an existing Theme Script

PUT /services/theme_scripts/{id}

You can update the exact script changing it source, event or scope.

Request
{
	"theme_script": {
		"src" : "https://www.shoplo.pl/example2.js",
	},
}
Response
HTTP/1.1 200 OK
{
	"theme_script": {
            "id": "7",
            "event_type": "onload",
            "src": "https://www.shoplo.pl/example2.js",
            "scope": "order_status",
            "created_at": "2018-07-23 19:05:08",
            "updated_at": "2018-07-23 19:05:08"
        }
}

Delete a Theme Script

DELETE /services/theme_scripts/{id}

You can delete each script by id

HTTP/1.1 200 OK
{
	"status"	: "ok",
}