musti4300 Posted October 17, 2016 Share Posted October 17, 2016 HiI want to implement this code in prestashop to show users how many hours left to ship this product today. $(document).ready(function () { setInterval(function () { var now = new Date(); var day = now.getDay(); var end; if(day >= 1 && day <= 5) { end = new Date(now.getYear(), now.getMonth(), day, 18, 0, 0, 0); } else { end = new Date(now.getYear(), now.getMonth(), day, 15, 0, 0, 0); } var timeleft = end.getTime() - now.getTime(); var diff = new Date(timeleft); $("#timeleft").html("Order now and we ship your order in: " + diff.getHours() + "h " + diff.getMinutes() + "Min " + diff.getSeconds() + "Sec"); }, 1000);});<div id="timeleft">Order now and we ship your order in:</div>Please tell me, where to place javascript so it works. Iv tried in product.tpl but it dosnt work. Please look at the below image. Link to comment Share on other sites More sharing options...
rocky Posted October 18, 2016 Share Posted October 18, 2016 It works fine in product.tpl on my PrestaShop v1.6.1.7 test site when I insert the following: <script type="text/javascript"> $(document).ready(function () { setInterval(function () { var now = new Date(); var day = now.getDay(); var end; if(day >= 1 && day <= 5) { end = new Date(now.getYear(), now.getMonth(), day, 18, 0, 0, 0); } else { end = new Date(now.getYear(), now.getMonth(), day, 15, 0, 0, 0); } var timeleft = end.getTime() - now.getTime(); var diff = new Date(timeleft); $("#timeleft").html("Order now and we ship your order in: " + diff.getHours() + "h " + diff.getMinutes() + "Min " + diff.getSeconds() + "Sec"); }, 1000); }); </script> <div id="timeleft">Order now and we ship your order in:</div> Check to make sure you don't have any JavaScript errors preventing the code from running. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now