I coded this a while back and have found it of great use. I am not sure if I would work internationally and very much probably depends on server set up, but I thought I would share it.
If you want to display a order dispatch estimate dependant on the current time and day of week, simply add this somewhere on your website, where depends on if you change your working I guess but you can customise it to your requirments. The example is designed to go:
includes/templates/YOUR_TEMPLATE/templates/product_info_display.php
the above logic does not take into account bank holidays and holidays.PHP Code:<!--start dispatch estimate -->
<?php
$timenow = date("H:i");
$daynow = date("D");
//debug
//$daynow = "Sun";
//$timenow = "15:00";
//use below variables if you wish to specify the dispatch date instead of just today or tomorrow..
//$nextMonday = date('j F Y', strtotime('next monday'));
//$tomorrow = mktime(0, 0, 0, date("m"), date("d")+1, date("y"));
//$tomorrowdate = date("l, j F Y", $tomorrow);
//
//debug
//echo $nextMonday;
if ($timenow < "14:55") { //change this to your order cut off time
if ($daynow == "Mon" || $daynow == "Tue" || $daynow == "Wed" || $daynow == "Thu" || $daynow == "Fri") {
echo "Order now for dispatch today";
} else {
echo "Order now for dispatch Monday";
} // end day check
} else {
if ($daynow == "Mon" || $daynow == "Tue" || $daynow == "Wed" || $daynow == "Thu") {
echo "Order now for dispatch tomorrow!";
} else {
echo "Order now for dispatch Monday!";
}
} // end time check
?>
<!--end dispatch estimate -->
the above logic is as follows
- ordering before 15:00 on Mon-Fri orders are dispatched same day
- ordering after 15:00 Mon-Thur orders are dispatched next day
- ordering After 15:00 friday or over sat & sun orders are dispatched Monday.
The logic can be played around with to achieve what ever you like.
Hope you find it useful![]()


Reply With Quote
