Click here to watch screencast.
My design for the shopping cart will be similar to Amazon's shopping cart, where the user will be taken to a separate webpage to view all their items and the quantities. The shopping cart will work by checking first to see if they are logged in. Then, by having that user information in the session, it will remember what the user has put into their shopping cart so that if they leave the site and come back, their products will still be in there. Then, from whatever quantities they decide to purchase from each item, it will show up in the shopping cart, where the user will be able to change the quantity by putting in a different number. Once they are ready to check out, they just click checkout and they will be redirected to the invoice page where they will be shown what they purchased and their total.
One example of using the shopping cart will be if the user decides to purchase a specific keyboard, they will be able to view it in their shopping cart. Then say they want to buy a certain amount of switches for that keyboard, they can go to the switches page and add the amount of switches they want. Then if they realized they need more switches, they can go into their cart and change the amount of switches they want to buy to the correct amount. Another example would be if they realized they wanted to purchase a different keyboard, they can go into their cart and remove the previously selected keyboard and select the keyboard they actually want to purchase and put it in the cart.
I would create an object, and in that object would include different arrays for each product, so that the cart will be able to recognize what product will be purchased and how many products will be purchased. An example of the array code would be: "Keyboard":[ { "name": "Tofu65", "price": 150, “quantity_purchased”: 0}. To request data from the session, I would use something like “request.session”.
By using cookies, the server can check to see if that user has cookies. If the user logged in, they would have a cookie for that session, if not, they wouldn’t. Then, by running validations on the check out button, we can check to see if the user has cookies or not, if they do then they will have access to purchasing the items in their cart, and if not then they will be prompted to log in. Some security concerns I must address will be if the user has left the website inactive for too long. This could be a security reason as if they forgot to log out, someone could go on the same computer and use their account to purchase things. To fix this, I would set a timer on the cookie by giving it an age, in milliseconds, so that when the timer is up the cookie will expire, which would then log the user out.
Upon a successful login, I would personalize my site by giving them a welcome page with their name right after they log in. I would also put their name in a thank you message after they have purchased their products and send them an email with their invoice.
I am working alone.
I am definitely starting the assignment earlier and thinking more about what to do and planning it out better, step by step. This allows me to work more efficiently as I have a dedicated plan that I can follow. I will also restart from the ground so that my site looks cleaner, and just pull certain code from assignment 2 and use it in assignment 3. This way I can make the changes I need easily and not get stuck just trying to modify assignment 2.