How to access additional metafields in V3 Template
Learn how to access and use additional metafields in your V3 Template implementation
Overview
In V3 Template, products are fetched using GraphQL. While default product data is automatically included, accessing additional metafields requires three steps:
- Adding metafields to the
getProductDetailsQuery
function - Including metafields in the
transformProductData
function - Accessing the metafields in your template’s theme.liquid
Basic Implementation
Step 1: Modify getProductDetailsQuery
Add your metafields to the GraphQL query in the getProductDetailsQuery
function:
Step 2: Update transformProductData
Modify the transformProductData
function to include your metafields:
Step 3: Access in Theme
Use the transformed metafield in your theme.liquid:
Practical Example: Product Ratings with Judge.me
Prerequisites
-
Install Judge.me app on your Shopify store:
- Go to Shopify App Store and install Judge.me
- Enable the app integration in your store settings
-
Enable Judge.me in Glood:
- Navigate to Glood Product Recommendations
- Go to Settings >> Integrations >> Product Review Apps
- Enable the Judge.me app integration
After completing the setup, the rating metafields will be available in your GraphQL queries. You can query these metafields using the reviews namespace wherever needed.
To display product ratings in your template, simply use the Judge.me liquid tag: