So once again you're sitting around thinking about your web site, as you often
do, and you decide you want to take orders on-line. You sell a few products and
make a nice little living, but there's no way you can afford a so called
e-commerce solution from one of the big guys, so as always you decide that it
just isn't cost effective... until you find this sample!
Now let me just tell you up front that this is by no means an end to end
solution. It specifically DOES NOT tackle the security issue, a big one as
we all know. Here's what it does cover: It will store a users product choices,
calculate a quick total and pass the results to an e-mail, text file, or whatever
other data source you feel like attaching it to. (Note this isn't done here since
we aren't selling anything, but take a look at the textfile and database samples
if you're interested!) We've tried to make it fairly easy to add on to by keeping
a lot of the code in self contained functions. You also don't need to use this to
list your products! You can simply call it to add and delete items and to check out!
In fact that's probably the best way to do it so that your data is separate from the
processing. Once again, our efforts to keep it simple sort of preclude our creating
a whole site to support the sample. Just make sure you pass it the correct action,
item id and quantity parameters and it should take care of the rest!
You'll notice we sort of just stop when we get to the actual order handling. It's
really not that we want to leave you hanging, but everybody's situation is a little
different and the processing would need to reflect that.
If anyone actually decides to use this prototype for anything, first let us say
Good Luck. ;) Secondly, let us know. We can help you wade through the
code and understand our thinking (or lack there of)! We'd also be very interested
in seeeing the end result if anyone does decide to take this sample to completion
and run it live on the Web.
Finally, note the lack of a Cool-Looking UI! This site is NOT "Pretty Web Site 101"
and we never promised that this code could be used without you taking the time to
make it look pretty. We probably should have encapsulated the HTML into functions to
make it easier to edit and update later; unfortunately... we didn't. If we need to make
any adjustments to it later, maybe we'll incorporate that then. Until then, sorry but you'll
need to experiment to get it to look like the rest of your site.
Update:
Based on user feedback we've made some changes to the sample code.
It now illustrates how to send the cart contents via email and
includes a new function to calculate an order's shipping cost.
We also took the opportunity to neaten up the HTML used throughout.
That being said, don't expect miracles. The sample is really old. It relies
heavily on render functions and in retrospect the use of the dictionary object
might not have been the best choice. Once I get the ASP.NET version written,
I plan to come back and do a proper rewrite of the classic ASP version.