Access a community of over 900,000 Shopify Merchants and Partners and engage in meaningful conversations with your peers.
Like it says in the title:
I have a client's site that uses Yotpo for reviews and such. It works fine, but we want to make it so it doesn't feature on any page where there aren't any reviews. Clients get review requests in their email and, so long as they've left at least one, it's fine to have the reviews section feature. But how do I hide it when there aren't any reviews on a product? Someone on Reddit recommended the following to me but it didn't work:
Basically just adding the following code to product.liquid
<script>$(document).ready(function(){if (!$(Yotpo.getStars()).find("span:not('.yotpo-icon-empty-star')").length) $(Yotpo.widgets.main.selector).hide();});</script>
The body of the code
if (!$(Yotpo.getStars()).find("span:not('.yotpo-icon-empty-star')").length) $(Yotpo.widgets.main.selector).hide();
should work. I believe the problem is that $(document).ready() is only waiting for the page to load, not the yotpo widget.
Try wrapping the above code in yotpo.onAllWidgetsReady(function() {}) like this
yotpo.onAllWidgetsReady(function(){
if (!$(Yotpo.getStars()).find("span:not('.yotpo-icon-empty-star')").length)
$(Yotpo.widgets.main.selector).hide();
})
I think it will work but I wasn't able to test it out
Let me know if it does
this worked for me 🙂
.yotpo-no-reviews{
display:none;
}
User | RANK |
---|---|
40 | |
37 | |
30 | |
15 | |
12 |