10.1. One Last Sanity Check of Checkout

When you last worked on the shoppingcart view in Chapter 5, you created a simple table view with associated functionality that allowed the user to add or remove items from their PHP session-based cart.

As a quick reminder, here's the source code for the shoppingcart view:

<h1>Shopping Cart</h1> <div id='pleft'> <?php echo form_open(); ?> <table border='1' cellspacing='0' cellpadding='5'> <?php $TOTALPRICE = $_SESSION['totalprice']; if (count($_SESSION['cart'])){ foreach ($_SESSION['cart'] as $PID => $row){ $data = array( 'name' => "li_id[$PID]", 'value'=>$row['count'], 'id' => "li_id_$PID", 'class' => 'process', 'size' => 5 ); echo "<tr valign='top'>\n"; echo "<td>". form_input($data)."</td>\n"; echo "<td id='li_name_".$PID."'>". $row['name']."</td>\n"; echo "<td id='li_price_".$PID."'>". $row['price']."</td>\n"; echo "<td id='li_total_".$PID."'>".$row['price'] * $row['count']."</td>\n"; echo "<td><a href='#' onclick='javascript:jsRemoveProduct($PID)'> delete</a></td>\n"; echo "</tr>\n"; } $total_data = array('name' => 'total', 'id'=>'total', 'value' => $TOTALPRICE); echo "<tr valign='top'>\n"; echo "<td colspan='3'>&nbsp;</td>\n"; echo "<td colspan='2'>$TOTALPRICE ".form_hidden($total_data)."</td>\n"; echo "</tr>\n"; echo "<tr valign='top'>\n"; echo "<td colspan='3'>&nbsp;</td>\n"; echo "<td colspan='2'><input type='button' name='update' value='update' onClick='javascript:jsUpdateCart()'/></td>\n"; echo "</tr>\n"; echo "<tr valign='top'>\n"; ...

Get Professional CodeIgniter® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.