Quantcast
Channel: Opinion: Shopify Community - Shopify Apps
Viewing all articles
Browse latest Browse all 11091

Benjamin C commented on Product Reviews Questions

$
0
0

Hello Alex, Ben here - your Shopify Guru!

 That tag only works within our app the view count is stored in a microdata attached to the products inside a metafield

You could work around this by writting the product reviews elements to the DOM inside a hidden div wrapper then parse the elements using some javascript to extract out the value of the review count which is stored inside a meta tag itemprop as "votes".

Here is an example of how this would work: 

<div class="review-parse-wrapper" style="display:none;" >
        {{ product.metafields.spr.reviews }}</div><div class="display-vote-count"></div> {% comment %} this is the holder for your review count {% endcomment %}<script>
       $(document).ready(function () {
           $('.display-vote-count').html($('meta[itemprop="votes"]').attr('content'));
           $('.review-parse-wrapper').html('');
       }); </script>

This code will write the review app metafield to a hidden <div> tag then extract it, and place it in the <div> with the class of "display-vote-count". You could move that <div> tag to where you wish to display the review count. 

I hope this helps! Feel free to reach out if you have any further questions :)

Cheers,
Ben Czegeny - Shopify Guru
Support@Shopify.com


Viewing all articles
Browse latest Browse all 11091

Trending Articles