Author Topic: Add a countdown timer to the cart page - Encourage customers to buy!  (Read 2214 times)

Offline hi_ts

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Add a countdown timer to the cart page - Encourage customers to buy!

I am looking to implement 2 key features:
1. Deducting the units added to the cart from the stock.
2. Adding a timer to the shopping cart (like 5 mins) and auto-delete from the cart if the checkout is not done before the timer expires.

Any suggestions will be very helpful. Many thanks. 

Offline Basara

  • Administrator
  • Hero Member
  • *****
  • Posts: 5774
  • Karma: +274/-2
    • View Profile
Re: Add a countdown timer to the cart page - Encourage customers to buy!
« Reply #1 on: September 13, 2021, 06:05:24 AM »
Hello.
You can create a block with the HTML including timer code and cart update javascript code https://abantecart.atlassian.net/wiki/spaces/AD/pages/12419073/HTML+Block

Offline HADY

  • Sr. Member
  • ****
  • Posts: 328
  • Karma: +27/-5
    • View Profile
Re: Add a countdown timer to the cart page - Encourage customers to buy!
« Reply #2 on: September 14, 2021, 10:32:02 AM »
Here is my suggestion to you :)




Code: [Select]
<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
p {
  text-align: center;
  font-size: 100px;
  margin-top: 100px;
}
</style>
</head>
<body>
<h1>Today</p>26.08.2021</p> At (13:15:00).</h1></p><h1>We'll be Online...</h1> </p>
<p id="demo"></p>

<script>
// Set the date we're counting down to
var countDownDate = new Date("August 26, 2021 13:15:00").getTime();

// Update the count down every 1 second
var x = setInterval(function() {

    // Get todays date and time
    var now = new Date().getTime();
   
    // Find the distance between now and the count down date
    var distance = countDownDate - now;
   
    // Time calculations for days, hours, minutes and seconds
    var days = Math.floor(distance / (1000 * 60 * 60 * 24));
    var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
    var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
    var seconds = Math.floor((distance % (1000 * 60)) / 1000);
   
    // Output the result in an element with id="demo"
    document.getElementById("demo").innerHTML = days + "d " + hours + "h "
    + minutes + "m " + seconds + "s ";
   
    // If the count down is over, write some text
    if (distance < 0) {
        clearInterval(x);
        document.getElementById("demo").innerHTML = "EXPIRED";
    }
}, 1000);
</script>

</body>
</html>
« Last Edit: September 15, 2021, 01:12:40 AM by Basara »
Thank you In Advanced
Regards
HADY

Offline Basara

  • Administrator
  • Hero Member
  • *****
  • Posts: 5774
  • Karma: +274/-2
    • View Profile
Re: Add a countdown timer to the cart page - Encourage customers to buy!
« Reply #3 on: September 15, 2021, 01:13:07 AM »
Thank you

Offline HADY

  • Sr. Member
  • ****
  • Posts: 328
  • Karma: +27/-5
    • View Profile
Re: Add a countdown timer to the cart page - Encourage customers to buy!
« Reply #4 on: September 15, 2021, 03:12:34 AM »
Thank you


Thank you for editing my reply too.
Thank you In Advanced
Regards
HADY

 

Powered by SMFPacks Social Login Mod