Skip to content

Instantly share code, notes, and snippets.

@Acen
Created May 4, 2022 23:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Acen/adc12e772e7843722b11c1a14ff6428b to your computer and use it in GitHub Desktop.
Save Acen/adc12e772e7843722b11c1a14ff6428b to your computer and use it in GitHub Desktop.
Shopify Review - on click go to tab & scroll into view
{% if block.type == 'reviews' %}
<script>
document.querySelector('.spr-starrating').classList.add('cursor-pointer')
document.querySelector(`div.spr-summary-starrating`).onclick = function (e) {
Array.from(document.querySelectorAll('.sf-tab-header')).find(el => el.textContent.includes("Product reviews")).click();
setTimeout(function(){
document.querySelector('div[data-id="{{ product.id }}"]').scrollIntoView();
}, 200)
}
</script>
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment