Writing a Shopping Cart
The most important aspect of the e-commerce site is the shopping cart itself. There are many types of carts out there, from a programming perspective, for many different purposes. What I'm going to write here is a generic cart class that can be adapted towards other e-commerce uses. But first, let's think about what a shopping cart should do:
Allow the customer to add items to the cart
Allow for different quantities of each item
Allow the customer to alter the quantities of an item
Allow the customer to remove an item
I'm going to write a shopping cart class that does all of this as well as displays the cart's contents. This last feature might also be placed in an extended class, as its particulars may change from application ...
Get PHP Advanced for the World Wide Web: Visual QuickPro Guide 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.