Zen Follower
- Join Date:
- May 2012
- Posts:
- 105
- Plugin Contributions:
- 0
Post #1 by soso838
I am trying to make a web site as http://1saleaday.com/wireless/
I want to have a add on for countdown timer or something that I can countrol the sales time
Started by soso838 on 23 Jul 2012, 10:04 PM · Views: 1,441
Zen Follower
I am trying to make a web site as http://1saleaday.com/wireless/
I want to have a add on for countdown timer or something that I can countrol the sales time
New Zenner
Hey All,
Zen Cart 1.5.5e and PHP 7.0
with Fast and easy checkout (fec) Numinix. https://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.php/Customisation_-_Templates_-_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:
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);
};
<div class="main__header">
</div>
<div id="time">
</div>
Any ideas?
Administrator
Not sure this is a good idea, since the order is in fact not reserved. If you have quantity 1, someone else can buy it underneath you, and you'd have a very unhappy customer ...
That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.
Totally Zenned
And if the system is changed to in fact "reserve" the item, what's to prevent someone from cycling through and keeping it/them in reserve indefinitely?
Certainly perhaps other text could be used to instill urgency, but like swguy said in summary, first to check-out wins...
ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...
Administrator
mc12345678:
And if the system is changed to in fact "reserve" the item, what's to prevent someone from cycling through and keeping it/them in reserve indefinitely?
Part of the "reserve" modification needs to be logic to prevent this kind of abuse. You might even associate a fee with the reservation.
That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.
New Zenner
That is true, you guys make a good point.
I would have to modify this with logic of course, but any ideas why I cant get get it to load inside the page using the on_load override??
Tell staff why this post should be reviewed.