|
Posted by Michael on 05/27/05 09:46
Can this code be improoved? If so how?
I am new to php. This is one of my first scripts.
Thank you
<?
define("TEXT_SHIP_TODAY", "<BR><B>Place your order today</B> before
<B>4:00pm Est.</B><br>Your order will ship by 5:00pm <B>Today.</B>");
define("TEXT_SHIP_FRITD", "<BR><B>Place your order today</B> before
<B>1:00pm Est.</B><br>Your order will ship by 2:00pm <B>Today.</B>");
define("TEXT_SHIP_TOMM", "<BR><B>Place your order today.</B><BR>Your order
will ship by 5:00pm Est on");
define("TEXT_SHIP_WEEKEND", "<BR><B>Place your order today.</B><BR>Your
order will ship by 5:00pm Est on");
define("HOLIDAY_SHIP_TEXT", "<BR><B>Due to the Holiday.</B><BR>If you place
your order today.<BR>Your order will ship by 5:00pm Est on");
define("TEXT_SHIP_TODAY_FRIDAY", "<BR><B>Place your order today before
1:00pm Est.</B><BR>Your order will ship by 5:00pm Est on");
define("PERD", ".");
$TDAY = date("D");
$TME = date("G:i:s");
$ORDER_WILL_SHIPA = date("l F jS");
$ORDER_WILL_SHIPB = date("l F jS", time()+86400); //86400 = 1 day this is
seconds
$ORDER_WILL_SHIPC = date("l F jS", time()+172800);
$ORDER_WILL_SHIPD = date("l F jS", time()+259200);
$ORDER_WILL_SHIPE = date("l F jS", time()+345600);
$ORDER_WILL_SHIPF = date("l F jS", time()+432000);
$DELAYDAYFL = date("F j");
//Define $IS_SHP_HOLIDAY true
if ($DELAYDAYFL == 'Nov 23' || $DELAYDAYFL == 'May 27' || $DELAYDAYFL ==
'Jul 1' || $DELAYDAYFL == 'Sep 2' || $DELAYDAYFL == 'Oct 7' || $DELAYDAYFL
== 'Nov 8' || $DELAYDAYFL == 'Nov 24' || $DELAYDAYFL == 'Dec 23' ||
$DELAYDAYFL == 'May 28' || $DELAYDAYFL == 'Jul 2' || $DELAYDAYFL == 'Sep 3'
|| $DELAYDAYFL == 'Oct 8' || $DELAYDAYFL == 'Nov 9' || $DELAYDAYFL == 'Nov
25' || $DELAYDAYFL == 'Dec 24' || $DELAYDAYFL == 'May 29' || $DELAYDAYFL ==
'Jul 3' || $DELAYDAYFL == 'Sep 4' || $DELAYDAYFL == 'Oct 9' || $DELAYDAYFL
== 'Dec 25' || $DELAYDAYFL == 'Jan 1' || $DELAYDAYFL == 'May 30' ||
$DELAYDAYFL == 'Jul 4' || $DELAYDAYFL == 'Sep 5' || $DELAYDAYFL == 'Oct 10'
|| $DELAYDAYFL == 'Dec 26' || $DELAYDAYFL == 'Jan 2') {${IS_SHP_HOLIDAY} =
'true';}
else $IS_SHP_HOLIDAY = 'false';
//Define Regular Weekday ship days
if ($TDAY == 'Mon' || $TDAY == 'Tue' || $TDAY == 'Wed' || $TDAY ==
'Thu'){$STDSHIPWD = 'true';}
else $STDSHIPWD = 'false' ;
if ($DELAYDAYFL == 'Nov 23'){${ORDER_WILL_SHIP} = HOLIDAY_SHIP_TEXT . ' ' .
$ORDER_WILL_SHIPF;}
if ($DELAYDAYFL == 'May 27' || $DELAYDAYFL == 'Jul 1' || $DELAYDAYFL == 'Sep
2' || $DELAYDAYFL == 'Oct 7' || $DELAYDAYFL == 'Nov 8' || $DELAYDAYFL ==
'Nov 24' || $DELAYDAYFL == 'Dec 23'){${ORDER_WILL_SHIP} = HOLIDAY_SHIP_TEXT
.. ' ' . $ORDER_WILL_SHIPE . PERD;}
if ($DELAYDAYFL == 'May 28' || $DELAYDAYFL == 'Jul 2' || $DELAYDAYFL == 'Sep
3' || $DELAYDAYFL == 'Oct 8' || $DELAYDAYFL == 'Nov 9' || $DELAYDAYFL ==
'Nov 25' || $DELAYDAYFL == 'Dec 24'){${ORDER_WILL_SHIP} = HOLIDAY_SHIP_TEXT
.. ' ' . $ORDER_WILL_SHIPD . PERD;}
if ($DELAYDAYFL == 'May 29' || $DELAYDAYFL == 'Jul 3' || $DELAYDAYFL == 'Sep
4' || $DELAYDAYFL == 'Oct 9' || $DELAYDAYFL == 'Dec 25' || $DELAYDAYFL ==
'Jan 1' ){${ORDER_WILL_SHIP} = HOLIDAY_SHIP_TEXT . ' ' . $ORDER_WILL_SHIPC .
PERD;}
if ($DELAYDAYFL == 'May 30' || $DELAYDAYFL == 'Jul 4' || $DELAYDAYFL == 'Sep
5' || $DELAYDAYFL == 'Oct 10' || $DELAYDAYFL == 'Dec 26' || $DELAYDAYFL ==
'Jan 2') {${ORDER_WILL_SHIP} = HOLIDAY_SHIP_TEXT . ' ' . $ORDER_WILL_SHIPB .
PERD;}
if ($STDSHIPWD == 'true' && $IS_SHP_HOLIDAY == 'false' && $TME <=
'16:00:00'){${ORDER_WILL_SHIP} = TEXT_SHIP_TODAY . ' ' . $ORDER_WILL_SHIPA .
PERD;}
if ($STDSHIPWD == 'true' && $IS_SHP_HOLIDAY == 'false' && $TME >
'16:00:00'){${ORDER_WILL_SHIP} = TEXT_SHIP_TOMM . ' ' . $ORDER_WILL_SHIPB .
PERD ;}
//weekend shipping
if ($TDAY == 'Fri' && $IS_SHP_HOLIDAY == 'false' && $TME >=
'13:00:00'){${ORDER_WILL_SHIP} = TEXT_SHIP_FRITD . ' ' . $ORDER_WILL_SHIPA .
PERD;}
if ($TDAY == 'Fri' && $IS_SHP_HOLIDAY == 'false' && $TME <
'13:00:00'){${ORDER_WILL_SHIP} = TEXT_SHIP_WEEKEND . ' ' . $ORDER_WILL_SHIPD
.. PERD;}
if ($TDAY == 'Sat' && $IS_SHP_HOLIDAY == 'false'){${ORDER_WILL_SHIP} =
TEXT_SHIP_WEEKEND . ' ' . $ORDER_WILL_SHIPC . PERD;}
if ($TDAY == 'Sun' && $IS_SHP_HOLIDAY == 'false'){${ORDER_WILL_SHIP} =
TEXT_SHIP_WEEKEND . ' ' . $ORDER_WILL_SHIPB . PERD;}
echo $ORDER_WILL_SHIP;
?>
Navigation:
[Reply to this message]
|