Upload
elfreda-bell
View
214
Download
0
Embed Size (px)
Citation preview
CIS 305 1
PHP – Chapter 27
Building A Shopping Cart
CIS 305 2
Shopping Cart Implementation
• A database of products to sell online• An online catalog of products, listed by category• A shopping cart to track items users want to buy• A checkout script that processes payments• An administration interface
CIS 305 3
The Book-O-Rama Shopping Car Problem
• Need to connect database to user’s browsers, so they are able to browse items by category
• Users should be able to select items for later purchase
• When they’re done, you need to total their order, take delivery details, and process payments
• You will need an administration interface so that administrators can add and edit books and categories
CIS 305 4
User Views
CIS 305 5
Administrator Views
CIS 305 6
System Modules• Catalog
– index.php, show_cat.php, show_book.php
• Shopping cart and order processing– show_cart.php, checkout.php, purchase.php,
process.php
• Administration– login.php, logout.php, admin.php,
change_password_form.php, etc…
• Function Libraries– book_sc_fns.php, admin_fns.php, book_fns.php,
order_fns.php, output_fns.php, data_valid_fns.php, db_fns.php, user_auth_fns.php
CIS 305 7
Book-O-Rama database tablescreate table customers1
( customerid int unsigned not null auto_increment primary key,
name char(60) not null,
address char(80) not null,
city char(30) not null,
state char(20),
zip char(10),
country char(20) not null );
create table orders1
( orderid int unsigned not null auto_increment primary key,
customerid int unsigned not null,
amount float(6,2),
date date not null,
order_status char(10),
ship_name char(60) not null,
ship_address char(80) not null, ship_city char(30) not null,
ship_state char(20), ship_zip char(10),
ship_country char(20) not null
);
CIS 305 8
Book-O-Rama database tablesOther tables: books1, categories1, order_items1, and admin1
• Transaction safe: type=InnoDB• Requires the use of
• autocommit(FALSE), commit(), autocommit(TRUE);
CIS 305 9
Bool-O-Rama Shopping Cart
• Demo
• Expanding the project:– Build an order tracking system– Add file upload for book pictures, etc.– Add book recommendations, online reviews,
stock level checking, etc…
• FishCartSQL: http://www.fishcart.org/