home -- outline -- lectures -- assignments -- discussion -- tips -- links --



Shopping Carts

The final project for this class will extend the Midterm Project to implement an online bookstore. In brief, the bookstore should allow people to put books in their shopping cart, maintain wish lists and buy books off your page.

In general, an online bookstore will have multiple customers. Hence, each time a new customer enters a bookstore, you must provide them with a "session-ID." The ID is stored as a cookie on the customer's computer (the client.)

The idea behind the "session-ID" is that the cookie "remembers" the customer's shopping cart, etc even when they leave the store and come back later. When the customer "checks out" (i.e. buys the books) you should delete the cookie because that particular "session" has ended.

Your online store must also have a provision to maintain "wish-lists." i.e. books that the customer might want to buy later but doesn't want to right now. You should use a separate "session-ID" for the wish-list since after the customer makes a purchase the shopping cart session-ID goes away but not the wish-list session-ID.

Once again, you should keep track of the customer's wish-lists on the server side.

Your bookstore will contain the same authors and books that you implemented for the midterm. Modify each page so that it allows the customer to add that particular book to the shopping cart. If she/he adds it twice, it should show up as two copies, etc.

Your online store must have the following behaviour :

  • If the customer doesn't have a current shopping session running, create a new shopping session ID for them. Similar for the wish list ID.
  • If they do have a current session running and they access your page again, then you must report (on the page, to the customer) if they have a shopping cart or a wish-list active.
  • Your book pages must have a mechanism of adding that book to the cart.
  • You must allow the customer to transfer books from their wish-list to their shopping cart and vice-versa.
  • The customer should be able to buy multiple copies of the same book if they want to.
  • There must be some provision to update the shopping cart i.e. change the number of copies, remove a book, etc.
  • You must have a checkout process which asks the customer for their address, etc and then proceeds to compute the tax, shipping and total cost as follows :
    • No tax for non-IL shipping addresses. IL residents are taxed at 8.75%.
    • Shipping Charges are as follows : $2 for the first book. Each sucessive copy costs $0.50 extra with a maximum shipping cost of $4
  • The checkout process should also ask for credit card numbers and expiration dates (month/year). Don't test the program out with real credit card numbers for rather obvious reasons.
  • Make sure that the order is saved in a reasonable format somewhere (where, presumably, it will be processed later.)
  • The shopping carts and wish-lists for the various customers must be maintained in a coherent logical fashion on the server side.
Some final instructions :
  • Create a subdirectory called "final" in the html directory of your classes account. The main page for the assignment should be called index.html in the "final" directory. Thus the URL for your page should be http://www.classes.cs.uchicago.edu/~student/final.
  • Note that the main page should contain some JavaScript because it needs to check cookies on the customer's computer and generate different pages based on whether the customer has a shopping cart session active or not and whether she/he has a wish-list active or not.
  • To generate a new sesson id in javascript use the following code:
    today = new Date();
    new_id = today.getTime();
    This makes new_id the number of milliseconds since 1 January 1970 00:00:00. On a real commerce site one should do something more complicated but for the purposes of this assignment this will work fine.
  • The shopping cart, wish list and check-out information should be kept in a special world-writable directory (otherwise your CGIs will not work.) Make sure you keep this information in a logical way. We recommend using the session id as the file name to store this information.
  • Once again, your project will not only be graded on correctness but also on whether it has a "professional" feel to it.
  • The final project is quite large. It involves intricate interaction between HTML, JavaScript and several CGI programs. It will help if you plan out the entire project before you start coding. We also recommend not trying to do the whole project at once. First start with just a shopping cart and then add the wish list later, for example.