I did not write this code, but it seems to have started causing a fatal error, though it hasn’t changed that I know of.
here is the code:
<?
require "./includes/cart_class.php";
require_once "./includes/functions.inc.php";
session_start();
//session_unregister('cart');
//exit();
$product_id = $_POST["pid"];
$pcid = $_POST["pcid"];
$product_name = $_POST["product_name"];
$price = $_POST["price"];
$qty = $_POST["qty"];
$att_id = $_POST["att_id"];
$att_value_id = $_POST["att_value_id"];
$pop = $_POST['pop']; /// if value =1 then comes from popup product details page.
$page_type = $_POST['page_type']; /// if value =1 then comes from category pages.
$stoolH = $_POST["stoolheight"];
$arr_att = array($att_id, $att_value_id);
$sql="select product_weight from yp_product where product_id='$product_id'";
$pweight=getSingleResult($sql);
if($_SESSION['cart']!=""){
$cart=$_SESSION['cart'];
}
if($qty==''){
if($min_qty!=""){
$qty=$min_qty;
}else{
$qty=1;
}
}
if($qty==0){
$_SESSION['sess_msg']= "QUANTITY CANNOT BE LESS THAN 1";
header("Location: product_detail.php?pid=$pid&pcid=$pcid");
exit();
}
if(!session_is_registered('cart')){
$cart = new cart();
session_register('cart');
}
$item_object = new product($product_id , $product_name , $price, $arr_att, $qty , $pweight, $stoolH);
$cart->addToCart($item_object);
$back="modify_cart_frm.php";
header("Location: ".$back);
exit;
?>
and this is the fatal error that you get when adding an item to the shopping cart AFTER you have already tried and were told your cart was empty. So the fatal error occurs after the second attempt at adding an item to your cart.
Fatal error: Call to a member function addToCart() on a non-object in /data/18/1/57/42/1220042/user/1300782/htdocs/add_to_cart.php on line 50
Is this code wrong? Does it look right?