Let??™s also take a look at the GetCartProducts() method. This method returns the products in the shopping cart.
It receives $cartProductsType as a parameter, which determines whether you??™re looking for the current shopping
cart products or for the products saved for later.
If $cartProductsType is equal to the GET_CART_PRODUCTS constant, GetCartProducts() will return the
shopping cart products. If $cartProductsType is equal to the GET_CART_SAVED_PRODUCTS constant,
GetCartProducts() will return the ???Save for later??? products. If $cartProductsType is neither GET_CART_
PRODUCTS nor GET_CART_SAVED_PRODUCTS, the method will raise an error.
All the other business tier methods you??™ve written basically call their associated data tier functions to perform the
various shopping cart tasks.
Implementing the Presentation Tier
Now let??™s build the user interface of the shopping cart. After updating the storefront, you??™ll have
Add to Cart buttons for each product and aView Cart link in the cart summary box on the left
part of the page. If the visitor??™s cart is empty, the link isn??™t displayed anymore, as you can see in
Figure 12-4.
Figure 12-4. The View Cart link doesn??™t show up if the cart is empty.
CHAPTER 12 ?– CREATING YOUR OWN SHOPPING CART 378
If you added PayPal integration as presented in Chapter 9, you already have these buttons
on your site, and you??™ll update their functionality here.
Pages:
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488