Shopping Application

  shop.py  

This is a full shopping application with shopping cart capability. It is written in Python, and uses cookies.  
Below is a list of components and their functions.


TablesDescription and Keys
shop_product This table holds product information such as product description, product type, price, etc.
Primary key: prod_id
shop_cust This table holds customer registration/profile information such as user, password, name, address, etc.
Primary key: cust_id
shop_cart This table holds customer shopping cart content such as product description, quantity, price, etc.
Primary key: item_id
Foreign keys: cust_id   and   prod_id
shop_order This table holds completed orders with data such as customer name & address, credit card, sales tax, etc.
Primary key: order_id
Foreign key: cust_id
shop_order_detail This table holds completed orders with data such as customer name & address, credit card, sales tax, etc.
Primary key: order_dtl_id
Foreign key: order_id
CookiesPurpose and Duration
cust_id This cookie is created once a user logs in successfully, and deleted once user logs out, or closes the browser.
Purpose: This cookie is retrieved in all subsequent pages. If no cookie, the user is redirected to the log in page.
Duration: temporary
cust_user This cookie is created once a user logs in successfully, and requesting that the userid be saved for future login sessions.
Purpose: The purpose of the cookie is to enable the customer not to have to enter their userid when logging in.
Duration: 7 days
Python PagesDescription and Functionality
Shop.py
  • This is the login entry point to the application.
  • Allows you to login or to register.
  • The script also allows you to log out. (This can also be done via a call from the other pages).
  • If logging in, the script retrieves the customer information from the shop_cust DB table.
  • A row must exist in the customer table, and the password must match what is entered.
  • If login is successful, the cust_id (from the shop_cust table) is saved as a temporary cookie,
    and the script redirects to the shopBrowse.py page.
  • The temporary cust_id cookie is used in all subsequent pages to ensure that customer has properly logged in.
  • The script allows the customer to save his/her userid. If so, cust_user cookie is saved for 7 days.
    Next time the customer logs in, he/she only needs to enter the password.
  • If register, the script redirects to the shopProf.py page.
  • If logging out, the temporary cust_id cookie is deleted.
ShopProf.py
  • This script allows you to either register a new user, or update profile for an existing user.
  • The script checks the temporary cust_id cookie.
  • If the cust_id cookie does not exist, this means a new registration.
  • If the cust_id cookie exists, this means it is an update to the customer previous profile information.
  • If new registration, the script allows you to enter a new userid, password, name, and other information.
  • The entered userid is checked against the database to ensure that it is unique, and does not already exist.
  • If OK, the data is inserted in the shop_cust DB table, with a newly generated cust_id value.
  • The cust_id is saved as temporary cookie to facilitate further processing.
  • If update to profile, the script allows you to update your registration profile within the shop_cust DB table.
  • The script does not allow you to change your userid, all other data can be changed.
  • The script also allow you to delete your customer profile. (This feature has been deactivated).
ShopBrowse.py
  • This script allows you to browse the product catalogue, and to add items to your shopping cart.
  • The script checks to see if cust_id cookie exists. If not exist, the script redirects you to the login shop.py page
  • The customer can scroll and search through the various available products.
  • The page allows the customer to add one or more products to a shopping cart.
  • The user adds items and quantities to the shopping cart
  • The script inserts or updates items into the customer's shop_cart DB table.
  • If the item quantity is reduced down to 0, the item is deleted from the shopping cart.
  • The user has the ability to view the cart. If so, the script redirects to the shopCart.py page.
  • The user also has the ability to checkout. If so, the script redirects to the shopCheckout.py page.
ShopCart.py
  • This script allows you to view and/or update the content of your shopping cart.
  • The script checks to see if cust_id cookie exists. If not exist, the script redirects you to the login shop.py page
  • The customer has the ability to change the quantity of a shopping cart item.
  • The customer can also delete an item or reduce its quantity to 0, which will also delete the item
  • The customer can either return to more shopping, in which case, the script redirects to the shopBrowse.py page.
  • Or, the customer can choose to checkout. In this case, the script redirects to the shopCheckout.py page.
ShopCheckout.py
  • This script allows you to checkout (add a new order) to the database.
  • The script checks to see if cust_id cookie exists. If not exist, the script redirects you to the login shop.py page
  • The script retrieves data from the shop_cust DB table and the shop_cart DB table.
  • Data is displayed on the screen.
  • The customer has the ability to change information (including name/address).
  • The customer can also return back to the shopping cart to change its content. If so, the script redirects to the shopCart.py page
  • Customer is asked to provide credit card information.
  • When customer clicks on "Place Order" button, the script inserts data into the cust_order and cust_order_detail DB tables.
  • The script also deletes all rows for the customer's shopping cart from the shop_cart DB table
ShopQuery.py
  • This script displays a list of all processed orders.
  • The script checks to see if cust_id cookie exists. If not exist, the script redirects you to the login shop.py page
  • The script retrieved all rows from the cust_order DB table and the cust_order_detail DB table, and displays those on the screen.
  • The client has the ability to sort (ascending & descending) by name, address, product ordered items, etc.
ShopSearch.py
  • This script displays all or some processed orders, and allows you to search/filter through the orders.
  • The script checks to see if cust_id cookie exists. If not exist, the script redirects you to the login shop.py page
  • The script retrieved all rows from the cust_order DB table and the cust_order_detail DB table, and displays those on the screen.
  • The script has the ability to search/filter for particular name, address, product ordered items, etc.
  • The client has the ability to sort (ascending & descending) by name, address, product ordered items, etc.