Chapter 12. Implementing the Shopping Basket

WHAT'S IN THIS CHAPTER?

  • Adding products to a basket via AJAX

  • Using the client's cookie to store a summary of the basket contents

  • Utilizing AJAX for the basket detail page when modifying the basket or shipping options

In Chapter 11, you enabled a customer to browse for products; this chapter addresses the needs of a customer to store the items they would like to order in a basket.

IMPLEMENTING THE BASKET

The basket implementation should use AJAX in all of its functionality, in keeping with the rich web 2.0 theme of the product browsing pages. Therefore, you will use AJAX to add, amend, and remove items from a basket, as well as select the dispatch options. A summary of the basket will appear on all product browsing pages, which will be stored in the client's cookie to enable faster page generation

Basket Domain Model

Figure 12-1 shows the domain model of the entities involved with the basket functionality.

FIGURE 12-1

Figure 12-1. FIGURE 12-1

Create a new folder within the Model project named Shipping, and add to it a new class named Courier that inherits from the EntityBase class that you created in the Infrastructure project.

using System.Collections.Generic; using Agathas.Storefront.Infrastructure.Domain; namespace Agathas.Storefront.Model.Shipping { public class Courier : EntityBase<int> { private readonly string _name; private readonly IEnumerable<ShippingService> ...

Get Professional ASP.NET Design Patterns 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.