Shopify examples
This page includes common use cases usually seen in Shopify catalog integrations.
Price
Prices are available at the variation level, under data.__prices, and scoped down to markets (e.g., data.__prices.US for the US market).
{
"metadata": [
{
"key": "price",
"value": data.__prices.US.price.amount
},
{
"key": "compareAtPrice",
"value": data.__prices.US.compareAtPrice.amount
}
]
}Inventory
Inventories are available in the variation level, under data.__inventory.
{
"metadata": [
{
"key": "availableInventory",
"value": data.__inventory.available
},
{
"key": "availableLocations",
"value": data.__inventory[available > 0].locationName
}
]
}Translations
Translations are available in the product level, under data.__translations.
(
$getTranslation := function($key) {
data.__translations[key = $key].value
};
{
"metadata": [
{
"key": "title",
"value": $or($getTranslation("meta_title"), data.title)
}
]
}
)Product metafields
Product level metafields are available under data.__metafields. You'll likely want to filter the metafield key to access a desired attribute.
(
{
"metadata": [
{
"key": "color",
"value": data.__metafields[key = "color"].value
}
]
}
)Variant metafields
Product level metafields are available under data.__variantMetafields. Similar to product metafields, you'll likely want to filter the metafield key to access a desired attribute.
(
{
"metadata": [
{
"key": "color",
"value": data.__variantMetafields[key = "color"].value
}
]
}
)Variant selected options
You can access selected options in the variation level at data.selectedOptions.
(
$selectedOptions := data.selectedOptions.({
"key": $snakeCase($.name),
"value": $.value
});
{
"metadata": $selectedOptions
}
)Metaobjects
Any metaobjects referred on metafields are automatically fetched if they are referred. Inside each metafield, you can access the metaobject data under __metaobjects.
{
"metadata": [
{
"key": "brand",
"value": data.__metafields[key = "brand"].__metaobjects.fields[key = "title"].value
}
]
}
Updated about 2 months ago