??? How to count or remove old shopping cart elements by building a simple shopping cart
administration page. This is important because without this feature, the shopping_cart
table keeps growing, filled with old temporary (and useless) carts.
Deleting Products Residing in the Shopping Cart
The catalog administration pages enable you to completely delete products from the catalog.
Before removing a product, you should also remove its appearances in visitors??™ shopping carts.
Update the catalog_delete_product function from the tshirtshop database by following
these steps:
1. Use phpMyAdmin to execute the code described in the following steps. Also, don??™t forget
to set $$ as the delimiter before executing the code at each step.
2. Execute the following code, which deletes the old catalog_delete_product stored
procedure from the tshirtshop database:
-- Drop the old catalog_delete_product stored procedure
DROP PROCEDURE catalog_delete_product$$
3. Execute this code, which creates the new catalog_delete_product stored procedure in
your tshirtshop database:
-- Create catalog_delete_product stored procedure
CREATE PROCEDURE catalog_delete_product(IN inProductId INT)
BEGIN
DELETE FROM product_attribute WHERE product_id = inProductId;
DELETE FROM product_category WHERE product_id = inProductId;
DELETE FROM shopping_cart WHERE product_id = inProductId;
DELETE FROM product WHERE product_id = inProductId;
END$$
CHAPTER 12 ?– CREATING YOUR OWN SHOPPING CART 392
Building the Shopping Cart Admin Page
The second problem with the shopping cart is that at this moment no mechanism exists to delete
the old records from the shopping_cart table.
Pages:
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502