_duplicate($id,$type)=="not") { $this->items[] = array(itemid=>"$id",itemqty=>"$qty",type=>"$type"); } else { for($i=0;$iitems);$i++) { if($this->items[$i]['itemid']== $id && $this->items[$i]['type']==$type) { //$this->items[$i]['itemqty'] = $qty; //replace $this->items[$i]['itemqty'] = $this->items[$i]['itemqty']+$qty; //increase break; } } } } function UpdateItem($id,$qty,$type) { for($i=0;$iitems);$i++) { if($this->items[$i]['itemid']== $id && $this->items[$i]['type']==$type) { $this->items[$i]['itemqty'] = $qty; //return $this->items[$i]['itemqty'];exit; break; } } } function RemoveItem($id,$type) { // loop thru array for($i=0;$i< count($this->items);$i++) { if($this->items[$i]['itemid']==$id && $this->items[$i]['type']==$type) { // Remove the Item in Cart unset($this->items[$i]); // Reindexing array $this->items = array_values($this->items); return true; } } return false; } function RemoveAll() { // delete whole array unset($this->items); } function _duplicate($id,$type) { $found = "not"; for($i=0;$iitems);$i++) { if($this->items[$i]['itemid']==$id && $this->items[$i]['type']==$type) { $found = "yes"; break; } } return $found; } function getItems() { return $this->items; } function getCount() { return count($this->items); } function getTotalItems() { $total_items=0; for($i=0;$iitems);$i++) { $total_items+=$this->items[$i]['itemqty']; } return $total_items; } } ?>