Storefront Metafields
Okendo writes a set of Shopify metafields whenever review or loyalty data changes. Most review data is written on the Product resource, with some aggregate data on the Shop resource, and loyalty data on the Customer resource. These metafields can be used in Liquid themes, headless storefronts, and custom theme sections to surface data without making additional API calls at render time.
Each metafield's Type refers to one of Shopify's basic metafield data types.
Metafield Scope
- Customer Metafields — Loyalty and profile data written per customer. Accessed via
customer.metafields.... - Product Metafields — Reviews data written per product. Accessed via
product.metafields.... - Shop Metafields — Reviews data written per shop. Accessed via
shop.metafields....
Accessing Metafields
Liquid
{{ product.metafields.app--1576377--reviews.reviews_widget_snippet }}
{{ product.metafields.reviews.rating }}
{{ product.metafields.reviews.rating_count }}
{{ shop.metafields.app--1576377--reviews.summary_data.reviewCount }}
{{ customer.metafields.app--1576377--loyalty.points_balance.value }}
Shopify Storefront API
Metafields can also be queried via the Shopify Storefront API, which is useful for headless storefronts. Okendo's metafield definitions are already exposed to the Storefront API, so no additional configuration is required.
Product metafields:
query ProductReviewMetafields {
product(id: "gid://shopify/Product/123") {
# App-scoped Okendo metafields (fully-qualified namespace)
reviewsWidget: metafield(namespace: "app--1576377--reviews", key: "reviews_widget_snippet") {
value
type
}
averageRating: metafield(namespace: "app--1576377--reviews", key: "average_rating") {
value
type
}
# Shopify-standard rating fields
rating: metafield(namespace: "reviews", key: "rating") {
value
type
}
ratingCount: metafield(namespace: "reviews", key: "rating_count") {
value
type
}
}
}
Shop metafields:
query ShopReviewSummary {
shop {
metafield(namespace: "app--1576377--reviews", key: "summary_data") {
value
type
}
}
}
Customer metafields:
query CustomerLoyaltyMetafields {
customer {
pointsBalance: metafield(namespace: "app--1576377--loyalty", key: "points_balance") {
value
type
}
status: metafield(namespace: "app--1576377--loyalty", key: "status") {
value
type
}
}
}
Note: The Storefront API returns each metafield's
valueas a string. Structured types (rating,json) are returned as serialized JSON strings that must be parsed client-side. A metafield that has been deleted (see Deleted Metafields) resolves tonull.
Feature Requirements
Some metafields are only written when certain Okendo features are enabled on the subscriber's account. Please contact us if you're experiencing issues accessing metafields on your store.
Deleted Metafields
When a product has no reviews, or a feature is disabled, certain metafields are deleted from Shopify rather than written with an empty value. Always guard against missing metafields in your storefront code.