If this is your first visit, check our documentation. To post, register or login.
Forums / General Questions / Display banner's Expiry date in store front

Display banner's Expiry date in store front

Started by gal_op on 25 Apr 2011, 2:23 AM · Views: 1,222

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

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

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

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

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