Liquid, JavaScript, themes, sales channels
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
Bit late, but there's a setting to turn this off!
It's called empty state in widget settings.
Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024Digital marketers and app developers have tracked activity in apps and websites for yea...
By Ollie Mar 13, 2024February was an exciting month with Shopify Editions, informative webinars, and more! F...
By JasonH Mar 7, 2024