Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save andreibabor/c239f1003a106c9ffd828f4d611bfee0 to your computer and use it in GitHub Desktop.
Save andreibabor/c239f1003a106c9ffd828f4d611bfee0 to your computer and use it in GitHub Desktop.
Shopify - Yotpo Don't show reviews when a product doesn't have any
<div class="yotpo bottomLine"
data-product-id="{{ product.id }}"
data-name="{{ product.title }}">
</div>
<style>
@keyframes nodeInserted {
from {
outline-color: #fff;
}
to {
outline-color: #000;
}
}
div.yotpo.bottomLine .star-clickable {
animation-duration: 0.01s;
animation-name: nodeInserted;
}
</style>
<script>
document.addEventListener('animationstart', function(event) {
if (event.animationName == 'nodeInserted') {
var ratingContent = document.querySelector(".yotpo-stars .sr-only").innerText;
if (ratingContent.includes('0.0')) {
document.getElementsByClassName('yotpo bottomLine')[0].style.display="none";
}
}
}, true);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment