I want to hide the Yotpo reviews section whenever a product has no reviews. Can someone help me?

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