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: