Rapid Reviews / Liquid Metafield Access
Liquid Metafield Access
You can access the following Rapid Reviews data directly from Shopify’s metafields for the entity types product
, collection
, page
, and shop
:
- Counts
- Data (First 12 reviews, First 12 questions — in reverse chronological order)
- Media (First 12 media items — in reverse chronological order)
Counts
Fields available for counts
are as follows:
- counts
- r (for Reviews)
- rating
- avg (average star rating for all reviews for this entity)
- counts
- core
- total (# of Reviews for this entity)
- liked (# of likes for all Reviews for this entity)
- reported (# of reports for all Reviews for this entity)
- core
- rating
- q (for Questions — same schema as above)
- r (for Reviews)
Data — Reviews & Questions (First 12)
Fields availble for data
are as follows:
- data
- r (Reivews first 12
typeof array
) - q (Questions first 12
typeof array
)
- r (Reivews first 12
Media (first 12)
- media
- media (Medias first 12
typeof array
)
- media (Medias first 12
~CE
<!-- SHOW STAR RATING IN LIQUID -->
{% assign thisRating = product.metafields.rapid_reviews.counts.value.r.rating.avg %}
{% unless thisRating %}{% assign thisRating = 0 %}{% endunless %}
<div class="rapid_reviews_stars_badge">
<a href="#rapid_reviews_items" tabindex="0" aria-label="Product review average">
<span class="r_stars">
<span class="r_stars_on" data-rating="{{ thisRating }}"></span>
</span>
({{ thisRating }})
</a>
</div>
<script>
// ASSIGN TO JAVASCRIPT OBJECT
var myCountsObject = {{ product.metafields.rapid_reviews.counts | json }}
var thisRating = myCountsObject && myCountsObject.r ? myCountsObject.r.rating.avg || 0
console.log('avg rating for this product', thisRating)
var myDataObject = {{ product.metafields.rapid_reviews.data | json }}
var thisReviewsList = myDataObject && myDataObject.r ? myDataObject.r || []
console.log('array of first 12 reviews for this product', thisReviewsList)
var myMediaObject = {{ product.metafields.rapid_reviews.media | json }}
var thisMediasList = myMediaObject && myMediaObject.media ? myMediaObject.media || []
console.log('array of first 12 medias for this product', thisMediasList)
</script>