|  | Posted by Flic on 02/02/07 16:17 
On 2 Feb, 15:30, Michael Fesser <neti...@gmx.de> wrote:> .oO(Flic)
 >
 > >Hi, I am a relative beginner with php and have run into the problem in
 > >the subject line. I wonder if anyone could point out what the problem
 > >is as I have tried a few different things and it still doesn't like
 > >it.
 >
 > >The code itself is:
 >
 > >if($_POST['add']) {
 > >    $product = $products[$_POST['id']];
 > >    $cart->add_item($product['id'],$product['price'],$product['name']);
 > >}
 >
 > >with the add_item line being the problem.
 >
 > The error message is pretty clear. Where is $cart coming from?
 >
 > Micha
 
 Ah, I checked and it was in the wrong file, the code I started with
 had everything on the same page and that bit was seperate from the
 rest of it so got missed on the move to two pages. As I said I've only
 just recently started this so it wasn't clear to me, I was looking at
 the actual in the add_item brackets.
 
 So thats that sorted, but its still not working properly. It adds an
 item but not the information for it, can anyone point out why?
 
 A bit more code:
 
 function add_item($itemid,$qty=1,$price = FALSE, $info = FALSE)
 { // adds an item to cart
 if($this->items[$itemid] > 0)
 { // the item is already in the cart..
 // so we'll just increase the quantity
 $this->itemqtys[$itemid] = $qty + $this->itemqtys[$itemid];
 $this->_update_total();
 } else {
 $this->items[]=$itemid;
 $this->itemqtys[$itemid] = $qty;
 $this->itemprices[$itemid] = $price;
 $this->iteminfo[$itemid] = $info;
 }
 $this->_update_total();
 } // end of add_item
 
 Once again any help appreciated! Thanks
 [Back to original message] |