Jump to content

Setting a cart item to '0' crashes internet explorer but works fine in firefox??


phpdragon

Recommended Posts

when viewing my cart, i added the ability to change the quantity of the items for each item, this works fine except in internet explorer when an item is set to '0' to remove it, it crashes with an error internet explorer cannot open site...Operation aborted

 

<?php session_start();
  if ($_SESSION["type"] != 'reseller') {
  header("Location: login_error.php");
  }
  require('req/definitions.php');
  $page = "Current Order";
  $userID = $_SESSION['userID'];
  include('data_connect.php');
$basket = $_POST['basket'];
$itemprice = $_POST['price'];
$itemqty = $_POST['quantity'];
$newprice = ($itemprice*$itemqty);
if (($basket!="") && (isset($_POST['submit']))){
   	if ($_SESSION['ses_basket_items']){
	// basket position
	$basket_position_counter=0;
	// double entry flag set to NO
	$double=0;
	// Check for existing basket name
	if ($_SESSION['ses_basket_items']>0){
	   foreach ($ses_basket_name as $basket_item){
	      if ($basket_item==$basket){
	         // If exist flag for update
			 $double=1;
	         $basket_position=$basket_position_counter;
	      }
		  // Add new basket position
	      $basket_position_counter++;
	   }
	}
	// Update basket with new quantity and price
	if ($double==1){
	   $ses_basket_amount[$basket_position]=$itemqty;
	   $ses_basket_price[$basket_position]=$newprice;
	}
}
// Delete Item when set to 0
if ($itemqty == "0") {
	array_splice ($ses_basket_name, $basket_position, 1);
	array_splice ($ses_basket_amount, $basket_position, 1);
	array_splice ($ses_basket_price, $basket_position, 1);
	array_splice ($ses_basket_stockcode, $basket_position, 1);
	array_splice ($ses_basket_id, $basket_position, 1);
	$_SESSION['ses_basket_items']--;
}
}
if ($_SESSION['ses_basket_items']==0){
unset($_SESSION['ses_basket_items']);
unset($_SESSION['ses_basket_name']);
unset($_SESSION['ses_basket_amount']);
unset($_SESSION['ses_basket_price']);
unset($_SESSION['ses_basket_stockcode']);
unset($_SESSION['ses_basket_id']);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php echo BIZ_NAME ?></title>
<script type="text/javascript" src="anylinkcssmenu.js">

/***********************************************
* AnyLink CSS Menu script v2.0- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Project Page at http://www.dynamicdrive.com/dynamicindex1/anylinkcss.htm for full source code
***********************************************/

</script>
<script type="text/javascript" language="javascript" src="scripts/lytebox_domload.js"></script>
<link href="site_layout.css" rel="stylesheet" type="text/css" />
<link href="anylinkcssmenu.css" rel="stylesheet" type="text/css" />
<link href="lytebox.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="970px" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td colspan="2" class="menutop"><table width="970" border="0" cellspacing="0" cellpadding="0">
  <tr>
     <td width="190px" height="40px"> </td>
    <td width="520px"> </td>
    <td width="260px" valign="middle" align="right"><b>User Control Panel</b>  </td>
  </tr>
  <tr>
    <td height="30px"> </td>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td width="190px" height="30px"> </td>
    <td valign="middle" class="order"><?php echo $_SESSION["type"]; if ($ses_basket_items>0) { $totalitems=array_sum($ses_basket_amount); ?>  -  <b><a href="<?php echo VIEWCART ?>">You have (<?php echo $totalitems; ?>) items currently on order.</a></b><?php } ?></td>
    <td> </td>
  </tr>
</table></td>
  </tr>
  <tr>
    <td class="menu_cell"><!-- Start Menu -->
      <?php include('menu.php'); ?>
      <!-- End Menu -->    </td>
    <td width="800" valign="top" align="center">
    <table border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td align="center" class="prodtable" width="800px"><br/><?php // View Current Cart Status
		if ($_SESSION['ses_basket_items']>0) { ?><table cellpadding='0' cellspacing='0' border='0' class="cartborder"><tr><td colspan="5"><table cellpadding='0' cellspacing='0' border='0'><tr><td width="190px" align="center" valign="middle" height="26px" class="stepon">ORDER STEP 1</td>
            <td width="190px" align="center" valign="middle" height="26px" class="stepoff">ORDER STEP 2</td>
            <td width="190px" align="center" valign="middle" height="26px" class="stepoff">ORDER STEP 3</td>
            <td width="190px" align="center" valign="middle" height="26px" class="stepoff">ORDER STEP 4</td>
          </tr></table></td></tr><tr><td colspan="5" align="left" class="carthead"> <font size="+1">PLEASE CHECK YOUR ORDER</font></td></tr>
            <tr><td width='320px' height='20' align='left' class='ordertitle'> ITEM</td><td align='left' height='20' class='ordertitle' width="110px">STOCK CODE</td><td align='left' height='20' width="90px" class='ordertitle'>UNIT PRICE</td><td align='left' height='20' width="140px" class='ordertitle'>QUANTITY</td><td class='ordertitle' height='20' align='right' width="100px">TOTALS </td></tr>
		<?php 
   			for ($basket_counter=0;$basket_counter<$_SESSION['ses_basket_items'];$basket_counter++){
      		$price=sprintf("%01.2f",$ses_basket_price[$basket_counter]);
      		$quantity=$ses_basket_amount[$basket_counter];
		$code=$ses_basket_stockcode[$basket_counter];
		$itemID=$ses_basket_id[$basket_counter];
      		$name=$ses_basket_name[$basket_counter];
		$unit=sprintf("%01.2f",($price/$quantity)); ?><form method='post' action='<?php echo $PHP_SELF; ?>' target="_self">
      		<tr><td align='left' class='rescon'><a href="prodshow.php?selected=<?php echo $itemID; ?>" title="ITEM: <?php echo $name. "  -  STOCK CODE: ".$code; ?>" rel="lyteframe[link]" rev='width: 700px; height: 480px; scrolling: yes;'><?php echo $name; ?></a></td><td align='left' class='rescon'><?php echo $code; ?></td><td align='left' class='rescon'>$<?php echo $unit; ?> ea</td><td align='left' class='rescon'><input name="price" type="hidden" value="<?php echo $unit; ?>"><input name="basket" type="hidden" value="<?php echo $name; ?>"><input name="quantity" style="vertical-align:middle;" type="text" value="<?php echo $quantity; ?>" size="5" maxlength="5"> <input type="submit" name="submit" style="vertical-align:middle;" value="Change"></td><td class='rescon' align='right'>$<?php echo $price; ?> </td></tr></form>
		<?php }  
   			$totalprice=sprintf("%01.2f",array_sum($ses_basket_price));
   			$totalitems=array_sum($ses_basket_amount); ?>
   			<tr><td align='left' colspan='3' class='cartbot'>CURRENT TOTALS:</td><td align='left' class='cartbot'><?php echo $totalitems; ?> items</td><td align='right' class='cartbot'>$<?php echo $totalprice; ?> </td></tr></table>
		<?php } else {
		echo "<div class='cartbot' align='center'>You have 0 item(s) in your cart.</div>";
}
if ($_SESSION['ses_basket_items']>0) { ?>
<table cellpadding='0' cellspacing='0' border='0'><tr><td height="30" valign="middle" align="center"><form name="checked" action="cart2.php" method="post" target="_self"><input type="submit" name="cart" value="CONFIRM AND PROCEED TO STEP 2" /></form></td></tr></table></td>
        </tr>
    </table><?php } ?></td>
  </tr>
  <tr>
    <!-- Start Bottom Link Bar -->
    <td class="link_bar" colspan="2"><a href="http://www.saint.com.au" target="_blank">© saint 2008 all rights reserved.</a></td>
    <!-- End Bottom Link Bar -->
  </tr>
</table>
</body>
</html>
<script type="text/javascript">
//anylinkcssmenu.init("menu_anchors_class") //call this function at the very *end* of the document!
anylinkcssmenu.init("anchorclass")
</script>

 

any ideas as to whats causing this behaviour, i have a similar feature when adding products to the cart from the catalog and this does not crash when setting(removing) item quantity to '0'

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.