Source code:
<?php
include ('include_pet_fns.php');
// The shopping cart needs sessions, so we start one
session_start();
$new = $_GET['new'];
if($new) {
//new item selected
if(!isset($_SESSION['cart'])) {
$_SESSION['cart'] = array();
$_SESSION['items'] = 0;
$_SESSION['total_price'] ='0.00';
}
$_SESSION['cart'][$new] = 1;
$_SESSION['total_price'] = calculate_price($_SESSION['cart']);
$_SESSION['items'] = calculate_items($_SESSION['cart']);
}
if(isset($_GET['close'])) {
foreach ($_SESSION['cart'] as $petid => $qty) {
if($_GET['erased']==$petid) {
unset($_SESSION['cart'][$petid]);
}
}
$_SESSION['total_price'] = calculate_price($_SESSION['cart']);
$_SESSION['items'] = calculate_items($_SESSION['cart']);
}
//print_r($_SESSION['cart']);
do_html_header('Your shopping cart');
$target = 'index.php';
echo '<table border="0" cellspacing="0" cellpadding="0" width="750">';
echo '<tr>';
echo '<td width="27%" style="padding-left:5px;padding-top:5px">';
echo '<img src="images/garfield2.jpg" width="202" height="243">';
echo '</td>';
echo '<td style="padding-right:10px;padding-bottom:60px">';
if($_SESSION['cart']&&array_count_values($_SESSION['cart'])) {
display_cart($_SESSION['cart'], false, 'ok'); // !!!!!
} else {
echo '<p class="species">There are no items in your cart</p>';
echo '<hr />';
}
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td style="padding-left:5px;padding-top:5px">';
echo '</td>';
echo '<td style="padding-right:5px;padding-top:5px">';
// if we have just added an item to the cart, continue shopping in that category
echo '<div align="right">';
if($new) {
$details = get_pet_details($new);
if($details['spid'])
$target = 'show_sp.php?spid='.$details['spid'];
}
display_button($target, 'continue-shopping', 'Continue Shopping');
/* use this if SSL is set up
$path = $_SERVER['PHP_SELF'];
$server = $_SERVER['SERVER_NAME'];
$path = str_replace('show_cart.php', '', $path);
display_button('https://'.$server.$path.'checkout.php',
'go-to-checkout-back', 'Go To Checkout');
*/
// if no SSL use below code
display_button('checkout.php', 'go-to-checkout-back', 'Go To Checkout');
echo '</div>';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td> </td>';
echo '<td> </td>';
echo '</tr>';
echo '</table>';
do_html_footer();
?>