Professional CodeIgniter

(singke) #1

Chapter 5: Building a Shopping Cart


113


Adding the View Cart Link to the Navigation


The second part of the Shopping Cart is very simple. You simply add a link that says “ view cart ” to the
main navigation if there are items in the customer ’ s Shopping Cart.

To do this, simply adjust the header view to look for contents in the cart session variable. If the cart
contains information, then show the link.

< a href=” < ?php echo base_url();? > ” >
< img src=” < ?php echo base_url();? > /images/logo.jpg” border=”0”/ >
< /a >
< div > < ?php echo anchor(“welcome/about_us”,”about us”);? > & nbsp;
< ?php echo anchor(“welcome/contact”, “contact”);? >
< ?php
if (count($_SESSION[‘cart’]) == true){
echo “ & nbsp;”. anchor(“welcome/cart”, “view cart”);
}
? >

Figure 5 - 3

What you should end up with is something that looks like Figure 5 - 3.
Free download pdf