Chapter 13. Building a Shopping Cart

This final section will bring together everything that has been previously demonstrated, as well as a variety of new things, into one large example. By the end of this section, we will have built a fully functional shopping cart.

Shopping Cart Requirements

Before building anything, I prefer to start with a definition of what I am going to build. The shopping cart that I will build will be targeted at buying books. I envision four different pages that a user can navigate:

Home page
The home page (all pages actually) will contain a list of categories that will help filter the genre of books. This will be displayed on the left-hand side. The righthand side will be used to display several featured books. Clicking a book will direct the user to the book details page.
Books by category
If a user clicks a category on the left-hand side, a list of books in that category will be displayed (similar to how featured books are displayed). Clicking a book will direct the user to the book details page.
Book details
The book details page is where users will go when they select a book. This page will display some basic information about the book and the all-important “Add to Cart” feature.
Cart details
Once an item is added to the cart, the cart details page will display all items currently in the user’s cart. This page will allow the user to edit the quantity or remove the item from the cart.

Using a shared layout, the category listing will be displayed ...

Get ASP.NET MVC 5 with Bootstrap and Knockout.js now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.