Last active
March 3, 2022 09:00
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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