0 && $quantity > 0 ) { $exists = addtocart($id,$quantity); if ( $exists == "exists" ){ $info = "fail"; } else { $info = "success"; } } else { $info = "fail"; } foreach ( $_SESSION['enquiry_basket'] as $index => $basket){ $total_basket += $basket['qty']; $sql_price = "SELECT `price_HKD` from `tb_product_list` where `id` = '".$basket['productid']."' AND `display` = '1'"; $row_price = $db->getrow($sql_price); $subtotal = $row_price['price_HKD'] * $basket['qty'] ; $total_price += $subtotal; $total_items++; } $total_list = $total_items."item(s),US$".$total_price.""; $data = array("info"=>$info,"total_items"=>$total_items,"total_list"=>$total_list); echo json_encode($data); ?>