Skip to content
This repository has been archived by the owner on Dec 2, 2019. It is now read-only.

Commit

Permalink
v1.3.0: Shopify Script Tags.
Browse files Browse the repository at this point in the history
  • Loading branch information
nozzlegear committed Jun 18, 2016
1 parent 5fef618 commit ee6d8b1
Showing 1 changed file with 75 additions and 1 deletion.
76 changes: 75 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ This library is still pretty new. It currently suppports the following Shopify A
- [Recurring application charges (subscriptions)](#recurring-application-charges-charge-shop-owners-to-use-your-app)
- [Shops](#shops)
- [Webhooks](#webhooks)
- [Script Tags](#script-tags)

More functionality will be added each week until it reachs full parity with Shopify's REST API.

Expand Down Expand Up @@ -377,7 +378,7 @@ await shop.forceUninstallApp();
import {Webhooks, Webhook} from "shopify-prime";

const service = new Webhooks(shopDomain, shopAccessToken);
const webhook: Webhook = {
let webhook: Webhook = {
address = "https://my.webhook.url.com/path",
topic = "themes/publish",
};
Expand Down Expand Up @@ -434,3 +435,76 @@ import {Webhooks, Webhook} from "shopify-prime";
const service = new Webhooks(shopDomain, shopAccessToken);
const webhooks: Webhook[] = await service.list();
```

## Script Tags

Script tags let you add remote javascript tags that are loaded into the pages of a shop's storefront, letting you
dynamically change the functionality of their shop without manually editing their store's template.

### Creating a script tag

```js
import {ScriptTags, ScriptTag} from "shopify-prime";

const service = new ScriptTags(shopDomain, shopAccessToken);
let tag: ScriptTag = {
event = "onload",
src = "https://example.com/my-javascript-file.js"
}

tag = await service.create(tag);
```

### Retrieving a script tag

```js
import {ScriptTags, ScriptTag} from "shopify-prime";

const service = new ScriptTags(shopDomain, shopAccessToken);
const tag = await service.get(tagId);
```

### Updating a script tag

```js
import {ScriptTags, ScriptTag} from "shopify-prime";

const service = new ScriptTags(shopDomain, shopAccessToken);
let tag = await service.get(tagId);

tag = await service.update(tag.id, {src: "https://example.com/my-new-javascript-file.js"});
```

### Deleting a script tag

```js
import {ScriptTags, ScriptTag} from "shopify-prime";

const service = new ScriptTags(shopDomain, shopAccessToken);

await service.delete(tagId);
```

### Counting script tags

```js
import {ScriptTags, ScriptTag} from "shopify-prime";

const service = new ScriptTags(shopDomain, shopAccessToken);
let count = await service.count();

//Optionally filter the count to only those tags with a specific Src
count = await service.count({src: "https://example.com/my-filtered-url.js"});
```

### Listing script tags

```js
import {ScriptTags, ScriptTag} from "shopify-prime";

const service = new ScriptTags(shopDomain, shopAccessToken);
let tags = await service.list();

//Optionally filter the list to only those tags with a specific Src
tags = await service.list({src: "https://example.com/my-filtered-url.js"});
```

0 comments on commit ee6d8b1

Please sign in to comment.