This solution of adding a new field breaks the rules of the third normal form, or simply said, it??™s not a perfect
database design; however, with some careful planning, it allows us to implement a functional shopping cart.
Implementing the Data Tier
Now we??™ll create the stored procedures that support the necessary shopping cart operations.
We??™ll create these procedures in the tshirtshop database:
??? shopping_cart_add_product adds a product to the shopping cart.
??? shopping_cart_update modifies shopping cart products??™ quantities and subsequent
pricing.
??? shopping_cart_remove_product deletes a product from the visitor??™s shopping cart.
??? shopping_cart_get_products gets the list of products in the specified shopping cart and
is called when you want to show the user the shopping cart.
CHAPTER 12 ?– CREATING YOUR OWN SHOPPING CART 367
??? shopping_cart_get_saved_products gets the list of products saved to buy later and is
called when the user requests the shopping cart details page.
??? shopping_cart_get_total_amount returns the total costs of the products in the specified
product cart.
??? shopping_cart_save_product_for_later saves a product to a shopping cart for later
purchase.
??? shopping_cart_move_product_to_cart moves a product from the ???Save for later??? list
back to the ???main??? shopping cart.
Now let??™s create each method one at a time in the following exercise.
Pages:
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476