Klaviyo Back in Stock button only appearing after refresh

New Member
1 0 0

Hi team,

I'm currenlty trying to implement the Klaviyo back in stock button. We're using the Wookiee theme and finally managed to get the button to show up, but for some reason the button only displays after you refresh the product page.


This is the code snippet I used in the product-template.liquid:

<script type="text/javascript">document.addEventListener("DOMContentLoaded", function(){ var _learnq = _learnq || [];var classname = document.getElementsByClassName("btn btn-lg btn-addtocart addtocart-js");var addToCart = function() {learnq.push(['track', 'Added to Cart', item]);}; for (var i = 0; i < classname.length; i++) {classname[i].addEventListener('click', addToCart, false); } });</script>

Would someone be able to help me with this?




Screen Shot 2021-11-03 at 8.41.06 am.png

Screen Shot 2021-11-02 at 12.59.16 pm.png

Replies 0 (0)