javascript – Adding my Countdown at the bottom of the cart


Today i add this code to my shop, it’s for adding a countdown at the top of the cart.

But i want to move it at the bottom of the cart (just above the “total on my shopify’s screenshot).

Here u have a screenshot of my cart-drawer :

cart drawer

Search : "<div class="h2 drawer__title">{{ 'cart.general.title' | t }}</div>"       
Transform by : "<div class="h2 drawer__title">{{ 'cart.general.title' | t }}<br></div>"
Add this between <br> and </div> : <h6><strong> Votre panier expire dans <span id="time" style="color: #4c51e0">10:00</span></strong></h6> <script type="text/javascript">
function startTimer(duration, display) {
    var timer = duration,
        minutes, seconds;
    setInterval(function() {
        minutes = parseInt(timer / 60, 10);
        seconds = parseInt(timer % 60, 10);

        minutes = minutes < 10 ? "0" + minutes : minutes;
        seconds = seconds < 10 ? "0" + seconds : seconds;

        display.textContent = minutes + ":" + seconds;

        if (--timer < 0) {
            timer = duration;
        }
    }, 1000);
}

window.onload = function() {
    var fiveMinutes = 60 * 10,
        display = document.querySelector('#time');
    startTimer(fiveMinutes, display);
}; </script>

So i do it and i have my timer at the top of the cart, but now i can’t move it to the bottom. I’m not very great for dev so if someone can help me 🙂

Thanks a lot !



Source link

Latest articles

Related articles

Leave a reply

Please enter your comment!
Please enter your name here