Average rating

Store the average customer rating for each of your products in a metafield and use it for product filtering in your admin or for logic purposes directly in your Liquid code. You can also trigger a workflow whenever your products' average rating change.

This is an expansion on the standard Shopify metafield reviews.rating which return your average review rating per product as a decimal number between 1 and 5. This use of this standard metafield is used by several review apps such as Judge.me, Shopify reviews etc.

Espresso mirrors the average rating from this metafield into another metafield designed specifically for admin filtering. The average rating is rounded to the nearest integer, giving an average rating between 1.0 and 5.0 in steps of 1.0. No reviews for a given product will yield an implicit rating of 0.0.

The calculated rating is assigned a label based on the value, as follows:

  • 5 = 5 ★★★★★
  • 4 = 4 ★★★★☆
  • 3 = 3 ★★★☆☆
  • 2 = 2 ★★☆☆☆
  • 1 = 1 ★☆☆☆☆
  • 0 = No rating

This approach gives you easy-to-use admin filter options to identify products based on their average review rating.

Details

  • Name
    espresso.average_rating
    Description

    Metafield namespace and key

  • Name
    metaobject_reference
    Description

    Metafield type. Using a metaobject reference instead of just a number allows for a better filtering experience in Shopify Admin.

  • Name
    product
    Description

    Scope of Shopify object that owns the metafield

Example content

{
    "value": 4,
    "label": "4 ★★★★☆"
}

When you initially enable this metafield, the individual product metafields will be set in a background task. If you have a large catalog, this may take anywhere from a few minutes to a few hours. Once the metafields are set, they will be updated in real-time

Flow trigger

Updates to this metafield fires a trigger that can used to start a Shopify Flow workflow.

  • Name
    product
    Description

    A reference to the product that owns the variants

  • Name
    avgRating
    Description

    The rounded average rating, one of 0.0, 1.0, 2.0, 3.0, 4.0, 5.0

  • Name
    avgRatingExact
    Description

    The calculated average rating, using 2 decimal places

  • Name
    avgRatingBefore
    Description

    The rounded average rating value before the update.

  • Name
    avgRatingExactBefore
    Description

    The calculated average rating value before the update.

Example content

{
    "product": "gid://shopify/Product/47953429430610",
    "avgRating": 3.0,
    "avgRatingExact": 3.50,
    "avgRatingBefore": 2.0,
    "avgRatingExactBefore": 2.90
}

Was this page helpful?