> I believe it is when it is shipped TO you. (When the
> customer can expect it to show up.)  
> ...
> Saturdays are a fixed rate of 35.99

Is it possible that Next Day could work out to be Saturday in your code? 
Example, if TodaysDate is 1/14/2010? 

But ignoring that question for a moment, you could certainly simplify the code 
with functions, etcetera. Another option might be to make it more database 
driven. My preference is to store certain types of settings in a database 
table, when possible. It is more dynamic and easier to modify on-the-fly.

For example you could store the delivery date logic in a small, two column 
table. The first column would represent day of week ordered (1-7). The second 
column would contain the number of days to add to determine the first possible 
shipping date (2,3,etc..). So to calculate the next possible ship date, just 
query the table. 

The cfloop could be replaced with a calendar table of dates. Then the dates for 
your select list could be generated by running a query against the calendar 
table.  I usually populate calendar tables with ample dates (like 50 or 100 
years). In addition to dates, you could also add a few BIT columns to store the 
common date properties used your application, such as "IsWeekDay","IsSaturday" 
and/or "IsSunday".  

The idea is to query the calendar table for desired date range (ie From 
#NewDate# to #NewDate# + 30 days), using some of the property columns to filter 
out the records you do not wish to display (like Sundays). Then use other 
properties in a CASE statement to calculate the price amount. The actual sql 
and CASE statements needed will almost certainly be different. But to give a 
very rough idea in psuedo-code:

   CASE 
      WHEN IsSaturday is true THEN Return #SaturdayPrice#
      WHEN CalendarDate equals #NewDate# THEN Return #NextDayPrice#
      WHEN CalendarDate equals #NewDate# + 1 day THEN Return #TwoDayPrice#
      WHEN IsWeekDay is true  THEN #StandardRate#
      ELSE ** Catch all value for unexpected conditions **
   END AS ShippingPrice
   ...

-Leigh


     

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:329727
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to