Shopify helper functions
You can use the helper functions listed below when developing templates for use with our Shopify connector.
$sanitizeId
$sanitizeId
Returns a sanitized Shopify ID field, removing the default Shopify prefix.
Template compatibility: All
Input
A string
Examples
$sanitizeId('gid://shopify/Product/123456')
=> '123456'
$mapTags
$mapTags
Maps Shopify product tags into an object. Keys are snake_cased
, and values are always arrays, with entries being trimmed. Tags with multiple values are always pushed into the same array.
Template compatibility: All
Input
string[]
, an optional separator string (:
by default).
Examples
Given the following product data:
{ "tags": ["color: red", "shoeSize:large", "shoeSize:medium"] }
You can use:
$mapTags(data.tags)
=> {
"color": ["red"],
"shoe_size": ["large", "medium"]
}
Updated 6 days ago