Hey All,
Zen Cart 1.5.5e and PHP 7.0
with Fast and easy checkout (fec) Numinix. www.slayitqueen.com
I am trying to add a Javascript timer to the billing details main_page=no_account (Numinix fec) to add urgency.
It says "An item you ordered is in high demand. Your order is reserved for (counts down from 10 mins)".
I tried to put in in includes/modules/pages/no_account and named it on_load_countdown.js as per: https://www.zen-cart.com/wiki/index....s_-_Javascript.
I can make it work in a browser no problem, but in zen cart? No.
It loads but outside the inner part of the page and only code shows. I put the Div class and ID of the navBreadCrumb in the code so that it would append, as that's where I want it to go (just after that, but cant get it to work.
Any ideas? Here is the javascript:
Code:
function create(htmlStr) {
var frag = document.createDocumentFragment(),
temp = document.createElement('div');
temp.innerHTML = htmlStr;
while (temp.firstChild) {
frag.appendChild(temp.firstChild);
}
return frag;
}
function startTimer(duration, display) {
var start = Date.now(),
diff,
minutes,
seconds;
function timer() {
diff = duration - (((Date.now() - start) / 1000) | 0);
minutes = (diff / 60) | 0;
seconds = (diff % 60) | 0;
minutes = minutes < 10 ? "0" + minutes : minutes;
seconds = seconds < 10 ? "0" + seconds : seconds;
display.textContent = minutes + ":" + seconds;
if (diff <= 0) {
start = Date.now() + 1000;
}
};
timer();
setInterval(timer, 1000);
}
window.onload = function () {
var fragment3 = create('<div style="background:#fff0f2 ;padding:10px 20px;border:1px solid #e3df74; font-size:14px; color:#2c2c2c; font-weight:bold;-webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; margin:10px 0px 20px 0px">An item you ordered is in high demand. Your order is reserved for <span id="time"></span> minutes!</div>');
document.getElementsByClassName('main__header')[0].appendChild(fragment3);
var ten = 60 * 10,
display = document.querySelector('#time');
startTimer(ten, display);
};
HTML Code:
<div class="main__header">
</div>
<div id="time">
</div>
Any ideas?
Bookmarks