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
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