Forums / General Questions / SHOW Specials Start and Expirey dates

SHOW Specials Start and Expirey dates

Locked

Views: 5,265

Results 1 to 17 of 17
This thread is locked. New replies are disabled.
7 Nov 2007, 6:11 PM
#1
fromtheriviera avatar

fromtheriviera

New Zenner

Join Date:
Aug 2007
Location:
South of France
Posts:
45
Plugin Contributions:
0

SHOW Specials Start and Expirey dates

Hello,

Currently have 30 products on Special promotion for xmas.
Want customers to know when the promotion expires as they are not exactly running to buy them thinking that the promotion is going to last forever.
No indication for customer when product promotion starts/ends .

Imagine the sales at your mega wallmart superstore where they post
.SALE 50% off everything and don't precise until when ?

I am sure that this would upset more than one customer who arrived too late
shouting at the poor cahsier "WELL WHY DIDN'T YOU TELL ME !!!??!!@#"

I have tried to find a solution in the forum as this is a must for any serious shopkeeper.

http://www.zen-cart.com/forum/showthread.php?t=44892
http://www.zen-cart.com/forum/showthread.php?t=40998
http://www.zen-cart.com/forum/showthread.php?t=46547
http://www.zen-cart.com/forum/showthread.php?t=44892
http://www.zen-cart.com/forum/showthread.php?t=65767
http://www.zen-cart.com/forum/showthread.php?t=1135

Has anyone actually found a working solution for non developers to be able to implement this ?

Which mudule(s) exactly should be updated and with what exact code ?

I get the feeling here that we are touching a subject that has more to it than meets the eye .... ?

Anyone's help would be appreciated...

My Favourite desert is zen-tart.

7 Nov 2007, 6:37 PM
#2
ajeh avatar

ajeh

Oba-san

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

Re: SHOW Specials Start and Expirey dates

Make a file in the functions extra directory:
/includes/functions/extra_functions/myfunctions.php

Add to it:

<?php
// extra functions

  function zen_get_specials_start($product_id) {
    global $db;
    $sql = "SELECT specials_date_available from " . TABLE_SPECIALS . "
            WHERE products_id = '" . (int)$product_id . "'";

    $check_specials_start = $db->Execute($sql);
    return $check_specials_start->fields['specials_date_available'];
  }

  function zen_get_specials_end($product_id) {
    global $db;
    $sql = "SELECT expires_date from " . TABLE_SPECIALS . "
            WHERE products_id = '" . (int)$product_id . "'";

    $check_specials_start = $db->Execute($sql);
    return $check_specials_start->fields['expires_date'];
  }
?>

Now you can get the special start and end dates ...

Something like this in the product _info template:

<?php echo 'Special for Product: ' . $_GET['products_id'] . ' is ' . zen_date_short(zen_get_specials_start($_GET['products_id'])) . ' - ' . zen_date_short(zen_get_specials_end($_GET['products_id'])); ?>

Would give you for products_id 42:

Special for Product: 42 is 11/07/2007 - 11/14/2007

Now just figure out how to utilize it for your code where you really want it ... :smile:

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!

8 Nov 2007, 9:31 PM
#3
fromtheriviera avatar

fromtheriviera

New Zenner

Join Date:
Aug 2007
Location:
South of France
Posts:
45
Plugin Contributions:
0

Re: SHOW Specials Start and Expirey dates

I will try to put your recomendations in place this weekend.

As we are getting closer to xmas, the specials are really an essential selling tool I cannot do without and I want to play arround with having different promotions ovelapping to keep the clients interested.

Sincere Thanks !

My Favourite desert is zen-tart.

17 Jan 2008, 1:05 PM
#4
fastcar avatar

fastcar

New Zenner

Join Date:
Dec 2007
Posts:
28
Plugin Contributions:
0

Re: SHOW Specials Start and Expirey dates

To bump an old thread:

I've just implemented this code myself to show the end date of an offer. However, the 'Offer Ends' text I have used in place of 'Specials For Product..' is visible on ALL products, not just those with special prices!

See an example here:

http://www.fastcardirect.co.uk/cart/index.php?main_page=product_info&cPath=91&products_id=959
Has a special price, works fine and looks good.

http://www.fastcardirect.co.uk/cart/index.php?main_page=product_info&cPath=15&products_id=926
Has 'Offer Ends:' but since there IS no offer, displays nothing else.

I'd assume it were a simple 'if' function. Example, if product has special; display 'Offer Ends: [End Date]', else Do Not Display.

However, I don't have the proper coding abilities to set this out in acceptable PHP.

Any help?

18 Jan 2008, 5:54 AM
#5
ajeh avatar

ajeh

Oba-san

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

Re: SHOW Specials Start and Expirey dates

If the date is: 0001-01-01

then there isn't a start date or end date as the case may be ...

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!

18 Jan 2008, 10:27 AM
#6
fastcar avatar

fastcar

New Zenner

Join Date:
Dec 2007
Posts:
28
Plugin Contributions:
0

Re: SHOW Specials Start and Expirey dates

Ajeh:

If the date is: 0001-01-01

then there isn't a start date or end date as the case may be ...

I realise this. It works fine (date-wise) but I would only like the text to display when a special price is applied, not to every product. If you browse the store you see that even products without specials have the 'Offer Ends' text there. I assume it's a case of surrounded the entire statement with a conditional 'if' but I wouldn't know where to start.

18 Jan 2008, 5:10 PM
#7
ajeh avatar

ajeh

Oba-san

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

Re: SHOW Specials Start and Expirey dates

The text needs to be written for display within an IF so that IF the date isn't to show, then nothing is displayed ... :smile:

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!

19 Jan 2008, 4:25 AM
#8
tamya avatar

tamya

Zen Follower

Join Date:
Feb 2007
Posts:
336
Plugin Contributions:
0

Re: SHOW Specials Start and Expirey dates

I know this code for a special and it can be changed to display the end of sales, but would it show the end of sales for items in category A if i created a new sale for catagory A.

21 Jan 2008, 7:48 PM
#9
fastcar avatar

fastcar

New Zenner

Join Date:
Dec 2007
Posts:
28
Plugin Contributions:
0

Re: SHOW Specials Start and Expirey dates

Ajeh:

The text needs to be written for display within an IF so that IF the date isn't to show, then nothing is displayed ... :smile:

Don't suppose you'd know the IF statement I'd need?

28 Sep 2008, 3:35 AM
#10
juxizoza avatar

juxizoza

Totally Zenned

Join Date:
Mar 2004
Posts:
651
Plugin Contributions:
1

Re: SHOW Specials Start and Expirey dates

Ajeh:

Now you can get the special start and end dates ...

Would give you for products_id 42:

Special for Product: 42 is 11/07/2007 - 11/14/2007

Now just figure out how to utilize it for your code where you really want it ... :smile:Linda,
Your ECHO is technically correct; however the special actually runs from 11/07/2007 - 11/13/2007.
The special is **not **available on the 'expires_date'.

How would you incorporate SUBDATE('expires_date', INTERVAL 1 DAY) into your proposed 'zen_get_specials_end' function?

Thank you,
Juxi

13 Nov 2008, 3:30 PM
#11
fastcar avatar

fastcar

New Zenner

Join Date:
Dec 2007
Posts:
28
Plugin Contributions:
0

Re: SHOW Specials Start and Expirey dates

To bump an old thread, I'm trying to do something similar in regards to the 'Offer Ends: ' text showing even without an offer on that product.

I understand that an 'if' statement is needed, all I need now is a point in the right direction.

So far I've got this in my tpl_product_info_display file:

<?php if (zen_date_short($specials_id, $status) !="" ) { 
	  echo 'Offer Ends: ' . zen_date_short(zen_get_specials_end($_GET['products_id']));
	} else {
	  echo '' . zen_date_short(zen_get_specials_end($_GET['products_id']));
	}
?>

Essentially this is giving me a special DATE showing on the products with specials, but no 'Offer Ends: ' text.

Any ideas?

15 Nov 2009, 1:27 PM
#12
chrisr avatar

chrisr

New Zenner

Join Date:
Nov 2006
Posts:
34
Plugin Contributions:
0

Re: SHOW Specials Start and Expirey dates

Hopefully this may help. As I am not a programmer it would be great to hear from anyone if this could could break something else or if it should be ok. Hopefully Ajeh could take a look and let me know.

I have added to the file posted by Ajeh. This is the
file that needs to go into includes/functions/extra_functions/show_specials_date_funtion.php
Ajeh called it myfunctions

 
<?php 
// extra functions 
// This function gets the data needed to display the Specials Start and End dates to the customer
// this files needs to be in the includes/functions/extra_functions directory.
// gets specials start date 
function zen_get_specials_start($product_id) { 
global $db; 
$sql = "SELECT specials_date_available from " . TABLE_SPECIALS . " 
WHERE products_id = '" . (int)$product_id . "'"; 
$check_specials_start = $db->Execute($sql); 
return $check_specials_start->fields['specials_date_available']; 
} 
// gest specials end date
function zen_get_specials_end($product_id) { 
global $db; 
$sql = "SELECT expires_date from " . TABLE_SPECIALS . " 
WHERE products_id = '" . (int)$product_id . "'"; 
$check_specials_start = $db->Execute($sql); 
return $check_specials_start->fields['expires_date']; 
} 
// gets specials status. 
// need this to stop date showing when special is still in special admin area deactivated
// but not removed. 
function zen_get_specials_status($product_id) { 
global $db; 
$sql = "SELECT status from " . TABLE_SPECIALS . " 
WHERE products_id = '" . (int)$product_id . "'"; 
$check_specials_start = $db->Execute($sql); 
return $check_specials_start->fields['status']; 
}
 
?>

Then in the includes/templates/YOURTEMPLATE/tpl_product_info_display.php you can add the following code

 
<?php
// Display Special start and end Date to customers so they know when the Special starts and finishes
// Gets status of special for current product 
$special_status_check = zen_get_specials_status($_GET['products_id'] );
// Gets the end date
// removes 1 day from the date as the special ends midnight of previous day enetered
// into the specials admin screen. So this will remove the day and display the correct 
// special end day. 
// Also changes date to Day, Month, Year. 
 $special_end_date = zen_date_short(zen_get_specials_end($_GET['products_id']));
     list($month,$day,$year) = explode('/', $special_end_date );
  $special_time = mktime(0, 0, 0, $month, $day, $year); 
  $special_time = strtotime('- 1 day', $special_time); 
  $special_end_date  = date('d/m/Y', $special_time); 
 
// Converts start date to Day, Month, Year
 $special_start_date = zen_date_short(zen_get_specials_start($_GET['products_id']));
     list($month,$day,$year) = explode('/', $special_start_date );
     $special_time = mktime(0, 0, 0, $month, $day, $year); 
     $special_start_date  = date('d/m/Y', $special_time); 
 
// Checks to see if it should display the specials date or not.   
 if ((zen_date_short(zen_get_specials_end($_GET['products_id'] )) =='') || ($special_status_check < 1))
  echo ""; 
 else
  echo 'Special for this product runs from: ' . $special_start_date . ' untill ' . $special_end_date;
?>
 

It works for me www.totallyautomated.eu
Please can someone take a look and let me know if I have managed to mess something else up by doing it this way.

Thanks:smile:

15 Nov 2009, 3:07 PM
#13
chrisr avatar

chrisr

New Zenner

Join Date:
Nov 2006
Posts:
34
Plugin Contributions:
0

Re: SHOW Specials Start and Expirey dates

Have updated and removed the start date from display.

16 Nov 2009, 9:13 AM
#14
chrisr avatar

chrisr

New Zenner

Join Date:
Nov 2006
Posts:
34
Plugin Contributions:
0

Re: SHOW Specials Start and Expirey dates

Have now also added to the CSS.

Need to change tpl_product_info_display.php

 
<?php
// Display Special start and end Date to customers so they know when the Special starts and finishes
// Gets status of special for current product 
$special_status_check = zen_get_specials_status($_GET['products_id'] );
 

to

 
<div class="specialdates"><?php
// Display Special start and end Date to customers so they know when the Special starts and finishes
// Gets status of special for current product 
$special_status_check = zen_get_specials_status($_GET['products_id'] );

and

 
//echo 'Special for this product runs from: ' . $special_start_date . ' until ' . $special_end_date;
echo 'Special for this product runs until ' . $special_end_date;
?>

to

 
//echo 'Special for this product runs from: ' . $special_start_date . ' until ' . $special_end_date;
echo 'Special for this product runs until ' . $special_end_date;
?></div>

in the includes/templates/YOURTEMPLATE
add the following

 
.specialdates {
 font-size: 1.4em;
 font-weight: bold;
 color: #0000CC;
 }

Hope it helps

16 Nov 2009, 6:10 PM
#16
chrisr avatar

chrisr

New Zenner

Join Date:
Nov 2006
Posts:
34
Plugin Contributions:
0

Re: SHOW Specials Start and Expirey dates

I have found an issue. It does not work correctly in another language. Can someone point me in the right direction to fix this.
Thanks:cry:

17 Dec 2009, 3:08 PM
#17
hater avatar

hater

New Zenner

Join Date:
Sep 2009
Posts:
6
Plugin Contributions:
0

Re: SHOW Specials Start and Expirey dates

Hello. Does anybody know how can i get this to the product_listing.
Please
Thanks