If the cart is empty, total_amount will be 0.
8. Execute the following code, which creates the shopping_cart_save_product_for_later stored procedure
in your tshirtshop database:
-- Create shopping_cart_save_product_for_later stored procedure
CREATE PROCEDURE shopping_cart_save_product_for_later(IN inItemId INT)
BEGIN
UPDATE shopping_cart
SET buy_now = false, quantity = 1
WHERE item_id = inItemId;
END$$
The shopping_cart_save_product_for_later stored procedure saves a shopping cart item to the
???Save for later??? list so the visitor can buy it later (the item isn??™t sent to checkout when placing the order).
This is accomplished by setting the value of the buy_now field to false.
9. Execute this code, which creates the shopping_cart_move_product_to_cart stored procedure in your
tshirtshop database:
-- Create shopping_cart_move_product_to_cart stored procedure
CREATE PROCEDURE shopping_cart_move_product_to_cart(IN inItemId INT)
BEGIN
UPDATE shopping_cart
SET buy_now = true, added_on = NOW()
WHERE item_id = inItemId;
END$$
The shopping_cart_move_product_to_cart stored procedure sets the buy_now state for a shopping
cart item to true, so the visitor can buy the product when placing the order.
CHAPTER 12 ?– CREATING YOUR OWN SHOPPING CART 371
Implementing the Business Tier
To implement the business tier for the shopping cart, we??™ll create a file named shopping_cart.
Pages:
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482