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": {
    "price": data.__prices.US.price.amount,
    "compareAtPrice": data.__prices.US.compareAtPrice.amount
  }
}

Inventory

Inventories are available in the variation level, under data.__inventory.

{
  "metadata": {
    "availableInventory": data.__inventory.available,
    "availableLocations": data.__inventory[available > 0].locationName
  }
}

Translations

Translations are available in the product level, under data.__translations.

(
  $getTranslation := function($key, $fallbackKey) {
    $or(
      data.__translations[key = $key].value,
      $lookup(data, $fallbackKey) /* fallback */
    )
  };

  {
    "metadata": {
      "title": $getTranslation("meta_title", "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": {
    "color": 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": {
    "color": 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": {
    "brand": data.__metafields[key = "brand"].__metaobjects.fields[key = "title"].value
  }
}