Professional CodeIgniter

(singke) #1

Chapter 5: Building a Shopping Cart


120


Please note the use of “ 1 records updated ” in the status message. In Chapter 10 , you learn how to
present users with grammatically correct messages. For here, the status message works well enough to
keep you on track.

The beauty of this approach is not just that the interface has been updated by the user, but now the
session has been too, asynchronously. If the user were to leave this page to continue shopping,
the session would be updated as well.

Adding a Delete Function to the Shopping Cart


The original mockup for the Shopping Cart view included a simple way for users to delete an item they
no longer wanted. At this point, if any user sets a product amount to 0, the item gets dropped, but that
isn ’ t very obvious.

So it ’ s time to add a simple delete function. You ’ ll do this in four steps:


  1. Update the shoppingcart view.

  2. Add a JavaScript handler.

  3. Update the Controller.

  4. Update the Model.


Figure 5 - 5
Free download pdf