Help - Search - Members - Calendar
Full Version: Countdown until product expires (Cubecart v3)
CubeCartForums.org Forum > CubeCart Version 3 > Request a Modification (v3)
comprido
Hi guys!

I´m looking a mod developer for this job:

1 - Modify/create an existing 'countdown' script for use in a CubeCart store (easily).

2 - Implement the new admin setting "EXPIRATION" to control the countdown.
ALL THE PRODUCTS WILL SHOW A COUNTDOWN, and when this countdown is finished the product DISSAPEARS/OR IS NOT VISIBLE so the visitors/clients cannot buy it.

3 - Implement changes to admin add/edit product so our final client can set a countdown price and countdown expire time (d m Y hh:mm).
The countdown will show: “XX days - XX:YY:ZZ” and the counter must be running.

CODE
<html>
<head>
<script type="text/javascript" language="JavaScript">
//año, poner un mes menos, dia, horas, minutos
var futuro = new Date (2011,05,5,19,45);
var actualiza = 1000;
function faltan(){
var ahora = new Date();
var faltan = futuro - ahora;
if (faltan > 0){
var segundos = Math.round(faltan/1000);
var minutos = Math.floor(segundos/60);
var segundos_s = segundos%60;
var horas = Math.floor(minutos/60);
var minutos_s = minutos%60;
var dias = Math.floor(horas/24);
var horas_s = horas%24;
document.formulario.reloj.value= dias + " dias : " + horas_s + " horas : " +
+minutos_s + " minutos : " + segundos_s + " segundos";
setTimeout("faltan()",actualiza);
}
else {
document.formulario.reloj.value= "La oferta ya no está disponible, lo siento.";
return true;
}
}
</script>
</head>
<body onLoad="faltan()" bgcolor="#0B111A">
<form name="formulario" style="font-family: Corbel; padding: 0">
<p align="center"><font face="Corbel">
<input type="text" name="reloj" value="" size="55" style="border-style:solid; border-width:0; padding:0; text-align : center; font-family:Corbel; color:#FF9900; background-color:#0B111A">
</font></p>
</form>
</body>
</html>


The idea is something like the megaupload method to show the files after 45 secs, but we need to show on every product page a counter (home/cat view/detailed view) as well as the countdown must be seteable from the Admin Panel.

Thanks in advance... I will heard offers.
GoChuggys
already sort of have this

pm sent
Degsey
There is already a mod which does this if you do a search.
comprido
QUOTE (Degsey @ Jun 1 2011, 02:04 AM) *
There is already a mod which does this if you do a search.


I have done without success. May you please post the URL exactly (via PM if you prefer).
Thanks in advance.
comprido
Have you seen http://1plusdesign.com/articles/add-countdown-timer-website/ and http://keith-wood.name/countdown.html, on tab "Callback Events" you will find the example that I´m looking for: "You can have a text message shown automatically on expiry".

Next step is implement in Cubecart shop...
comprido
I need to see the result before of paying, so if you think that it is a trouble, don´t get involved.

As you see all my mods & skins are free developed (http://www.cubecartforums.org/index.php?autocom=downloads&req=search&code=all_author&id=11640) so please be realist with your bill.

As I see at http://keith-wood.name/ , maybe a combination of jQuery Date/Time Entry and jQuery Countdown plugins would be the solution...

jQuery Date/Time Entry – Pick the date through field in edit/add product Admin page.
jQuery Countdown – Show the countdown and hide the buy buttons/product on finished at frontend, viewcat and detailed product view.

Anyone may help?

comprido
At this moment I have ALMOST done a mod to make a product expiration possible, I told almost as I´m reviewing to SET stock_level=0 or DELETE product when expired... any ideas are welcome!

POSSIBLE --> PRODUCT EXPIRATION DATE MOD FOR CUBECART 3.0.12 - 3.0.20

1.- Add a row to database product_inventory: `expires` datetime default '0000-00-00 00:00:00'

2.- In admin/product/index.php file:
AFTER:
$record["prodWeight"] = $db->mySQLSafe($_POST['prodWeight']);

INSERT:
/* product expiration mod */
$record["expires"] = $db->mySQLSafe($_POST['expires']);

AFTER:
<tr>
<td width="25%" class="tdText"><strong><?php echo $lang['admin']['products']['sale_price2'];?></strong><br />
<?php echo $lang['admin']['products']['sale_mode_desc'];?> </td>
<td><input name="sale_price" value="<?php if(isset($results[0]['sale_price'])) echo $results[0]['sale_price']; ?>" type="text" class="textbox" size="10" /></td>
</tr>

INSERT:
<!-- Product expiration mod -->
<tr>
<td class="tdText"><strong><?php echo $lang['admin']['products']['expires'];?></strong></td>
<td class="tdText"><input name="expires" type="text" class="textbox" size="18" value="<?php if(isset($results[0]['expires'])) echo $results[0]['expires']; ?>" /> <?php echo $config['expires']; ?></td>
</tr>
<tr>
<!-- Product expiration mod -->

3.- In YOUR LANGUAGE/S file/s:
AFTER
'prod_weight' => "Peso del Artículo:",

INSERT
'expires' => "Caduca:",

AFTER
$lang['front']['index'] = array(


INSERT
// Expiration mod
'expiration' => "Caduca:",

4.- In includes/index.inc.php

SEARCH for:
$latestProducts = $db->select("SELECT productId, image, price, name, sale_price FROM ".$glob['dbprefix']."CubeCart_inventory WHERE `showFeatured` = 1 ORDER BY productId DESC LIMIT ".$config['noLatestProds']);

REPLACE with:
$latestProducts = $db->select("SELECT productId, image, price, name, sale_price, expires FROM ".$glob['dbprefix']."CubeCart_inventory WHERE `showFeatured` = 1 AND expires >= now() ORDER BY productId DESC LIMIT ".$config['noLatestProds']);

5.- Optionally, advice your visitors about the product expiration.
Open skins/yourskin/styleTemplates/content/index.tpl and PUT <span class="txtDefault">{TXT_EXPIRATION}:{TXT_EXPIRES}</span> anywhere between the <!-- BEGIN: repeat_prods --> and <!-- END: repeat_prods --> to make it visible at the shop frontpage.

---------------------------------------------------------------------------
NOTICE THAT AT THIS POINT, THIS MOD JUST HIDE A PRODUCT EXPIRED IN THE SHOP HOMEPAGE
Brian Smither
Thank you!

The database table column could also be INT(10) to hold a PHP/UNIX timestamp value (valid between 1970 and 2038). In some cases, makes it easier comparing two moments in time.
comprido
Editing index.inc.php, may use:

// Expiration mod turns "0" the stock_level of expired products

$query = $db->select("UPDATE ".$glob['dbprefix']."CubeCart_inventory SET `stock_level` = 0 WHERE `expires` <= now() LIMIT ".$config['noLatestProds']);

and

// adding "AND expires >= now()" to hide the expired products

$latestProducts = $db->select("SELECT productId, image, price, name, sale_price, expires FROM ".$glob['dbprefix']."CubeCart_inventory WHERE `showFeatured` = 1 ORDER BY expires ASC LIMIT ".$config['noLatestProds']);

But it returns an error:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in ...


With this changes, and installation of MOD HIDE OUT OF STOCKS ITEMS - http://cc3.biz/cubecart-mods/cubecart-3-mo...1/prod_145.html the problem would be partially solved...

Ideas????
comprido
Please help, would it be enough modifying this code http://www.hashemian.com/tools/javascript-countdown.htm and, executing a hide product query to set stock to zero when the countdown finish, isn´t it?

So, editing index.inc.php I may use something like:

CODE
$clockcountdown = '<script language="JavaScript">
TargetDate = "15/06/2011 5:00 AM";
BackColor = "black";
ForeColor = "fuchsia";
CountActive = true;
CountStepper = -1;
LeadingZero = true;
DisplayFormat = "%%H%%:%%M%%:%%S%%";
FinishMessage = "Final!";
</script>
<script language="JavaScript" src="http://scripts.hashemian.com/js/countdown.js"></script>';


and:
CODE
$index->assign("COUNTDOWN_CLOCK", $clockcountdown);


and at least:
CODE
// Expiration mod turns "0" the stock_level of expired products
$query = $db->select("UPDATE ".$glob['dbprefix']."CubeCart_inventory SET `stock_level` = 0 WHERE `expires` <= now() LIMIT ".$config['noLatestProds']);


But, how can I call the TargetDate through the database (see here the PRODUCT EXPIRATION DATE MOD) and repeat this code for-each product at home, catview pages???



Uploaded with ImageShack.us

Thanks in advance!
comprido
Another problem... run the Javascript for various items in the same page...

Seems that bjm_x037 had the same trouble on August 15th, 2007, 11:17 AM smile.gif please take a sight at http://forums.devshed.com/javascript-devel...age-467569.html that mention the article "Multiple JavaScript Events Count Down Counter On Same Page for Blogs/Sites" at http://www.itskylineblog.com/2007/08/multi...count-down.html

Waiting responses... sad.gif
Degsey
The mod was for V4 called daily deals mod and the author is here

I believe the mod is no longer being sold but he may have the answers for you.
comprido
Nice, thanks!
comprido
QUOTE (Erik)
I'm not doing any mods at the moment.


Daily deals mod was developed for CC4 and author can´t help me at the moment, so this job is unsolved yet.
comprido
Good combination:
http://andrewu.co.uk/clj/countdown/ and http://jongsma.org/software/protoplasm/con...page=datepicker

Will work on it.

Just like http://es.groupalia.com, done with http://keith-wood.name/countdown.html mentioned before.
comprido
Mod Countdown Product Expiration para Cubecart 3.0.12 a 3.0.20 -
http://www.cubecartforums.org/index.php?au...mp;showfile=652
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2014 Invision Power Services, Inc.