90 likes | 252 Views
PHP – Chapter 27. Building A Shopping Cart. 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.
E N D
PHP – Chapter 27 Building A Shopping Cart CIS 305
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
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
User Views CIS 305
Administrator Views CIS 305
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
Book-O-Rama database tables create 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
Book-O-Rama database tables Other tables: books1, categories1, order_items1, and admin1 • Transaction safe: type=InnoDB • Requires the use of • autocommit(FALSE), commit(), autocommit(TRUE); CIS 305
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/ CIS 305