Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.
Forums / General Questions / General Questions / where can I find out the "discount count down by the time"

where can I find out the "discount count down by the time"

Started by soso838 on 23 Jul 2012, 10:04 PM · Views: 1,441

Results 1 to 6 of 6
23 Jul 2012, 10:04 PM
#1
soso838 avatar

soso838

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

18 Apr 2018, 12:07 PM
#2
one_pac avatar

one_pac

New Zenner

Join Date:
Dec 2017
Location:
Adelaide
Posts:
16
Plugin Contributions:
0

Post #2 by one_pac

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?

18 Apr 2018, 12:40 PM
#3
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,769
Plugin Contributions:
56

Post #3 by swguy

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.

18 Apr 2018, 2:33 PM
#4
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Post #4 by 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?

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...

18 Apr 2018, 3:24 PM
#5
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,769
Plugin Contributions:
56

Post #5 by swguy

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.

18 Apr 2018, 10:52 PM
#6
one_pac avatar

one_pac

New Zenner

Join Date:
Dec 2017
Location:
Adelaide
Posts:
16
Plugin Contributions:
0

Post #6 by one_pac

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??