-
Notifications
You must be signed in to change notification settings - Fork 706
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
131 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# ScriptTags | ||
|
||
ShopifyApp can manage your app's [ScriptTags](https://shopify.dev/docs/admin-api/graphql/reference/online-store/scripttag) for you by setting which scripttags you require in the initializer. | ||
|
||
## Configuration | ||
|
||
```ruby | ||
ShopifyApp.configure do |config| | ||
config.scripttags = [ | ||
# Basic script tag | ||
{cache: true, src: 'https://example.com/fancy.js'}, | ||
|
||
# Script tag with template_types for app block detection | ||
{ | ||
cache: true, | ||
src: 'https://example.com/product-script.js', | ||
template_types: ['product', 'collection'] | ||
} | ||
] | ||
end | ||
``` | ||
|
||
## Required Scopes | ||
Both the `write_script_tags` and `read_themes` scopes are required. | ||
|
||
For apps created with the Shopify CLI, set these scopes in your `shopify.app.toml` file: | ||
|
||
```toml | ||
[access_scopes] | ||
# Learn more at https://shopify.dev/docs/apps/tools/cli/configuration#access_scopes | ||
scopes = "write_products,write_script_tags,read_themes" | ||
``` | ||
|
||
For older apps, you can set the scopes in the initializer: | ||
|
||
```ruby | ||
config.scope = 'write_products,write_script_tags,read_themes' | ||
``` | ||
|
||
## How It Works | ||
|
||
### Script Tag Creation | ||
|
||
Scripttags are created in the same way as [Webhooks](/docs/shopify_app/webhooks.md), with a background job which will create the required scripttags. | ||
|
||
### App Block Detection | ||
|
||
When you specify `template_types` for a script tag, ShopifyApp will check if the store's active theme supports app blocks for those template types. If any template type doesn't support app blocks, the script tags will be created as a fallback | ||
|
||
This allows your app to automatically adapt to the store's theme capabilities, using app blocks when available and falling back to script tags when necessary. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters