Zen Cart Logo
Forums / General Questions / Display banner's Expiry date in store front

Display banner's Expiry date in store front

Views: 1,221

Results 1 to 6 of 6
25 Apr 2011, 2:23 AM
#1
gal_op avatar

gal_op

New Zenner

Join Date:
Apr 2010
Posts:
21
Plugin Contributions:
0

Display banner's Expiry date in store front

Hi There,

I want to use my main banner as a limited time deal offer.
When creating a banner i can set an expiry date for it.

Can anyone help me with writing a code that will show that expiry date somewhere in the front end of the store?

Thanks

27 Apr 2011, 5:22 AM
#2
gal_op avatar

gal_op

New Zenner

Join Date:
Apr 2010
Posts:
21
Plugin Contributions:
0

Re: Display banner's Expiry date in store front

I think i might need to write a function in banner.php that will return the expiry date.

function zen_expire_date_banners($identifier) {
    $banner = $identifier;
    global $db;
    $banners_query = "select b.banners_id, b.expires_date, b.expires_impressions,
                             sum(bh.banners_shown) as banners_shown
                      from " . TABLE_BANNERS . " b, " . TABLE_BANNERS_HISTORY . " bh
                      where b.status = 1
                      and b.banners_id = bh.banners_id
                      group by b.banners_id, b.expires_date, b.expires_impressions";

    $banners = $db->Execute($banners_query);

return $banners->fields['expires_date']

}

I think it will look something similar to the above.
And then i will call the function:

<div id="bannerSix" class="banners"><?php echo zen_expire_date_banners($banner); ?></div>

Any one care to share his thought?

27 Apr 2011, 2:37 PM
#3
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Display banner's Expiry date in store front

Try this for the function:

function zen_expire_date_banners($identifier) {
    global $db;
    $banners_query = "select b.banners_id, b.expires_date, b.expires_impressions
                      from " . TABLE_BANNERS . " b
                      where b.banners_id = '" . $identifier . "'";

    $banners = $db->Execute($banners_query);

    return $banners->fields['expires_date'];

}

Then at the bottom of the function zen_display_banner you could add something like:

$chk_banner_expires = zen_expire_date_banners($banner->fields['banners_id']);
$banner_string .= '<br>ID: ' . $banner->fields['banners_id'] . ' Expires on: ' . $chk_banner_expires;
    zen_update_banner_display_count($banner->fields['banners_id']);

Or clean that up to add the date as you want to display it ...

28 Apr 2011, 2:19 AM
#4
gal_op avatar

gal_op

New Zenner

Join Date:
Apr 2010
Posts:
21
Plugin Contributions:
0

Re: Display banner's Expiry date in store front

Thanks Ajeh,
This is working great. :)
I have implemented a jquery countdown to show the remaining time for the banner

you can see the development here: http://www.vibesdesign.com.au/tradies

28 Apr 2011, 2:44 AM
#5
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Display banner's Expiry date in store front

That looks pretty snazzy ... nice job! :smile:

Something like that I bet others would love to know how you did it ...

28 Apr 2011, 11:15 AM
#6
gal_op avatar

gal_op

New Zenner

Join Date:
Apr 2010
Posts:
21
Plugin Contributions:
0

Re: Display banner's Expiry date in store front

Thanks!

first i have downloaded this free jquery countdown script:
http://www.littlewebthings.com/projects/countdown/downloads/lwtCountdown-html.zip
Than i have placed all the jscript/css elements in my Zen Cart template folder.

Once this is done, i have placed the countdown html code into my tpl_header.php or wherever you like to show it.

In banner.php as discussed before i have added the functions posted by "Ajeh"
And tweaked them a bit to show "year", "month" and "Day" in seperate variables

Finally, replace the expiry date variables with the countdown script. ENJOY

Hope it was clear enough