in reply to Re: Need duplicate item entries in shopping cart
in thread Need duplicate item entries in shopping cart
sub add_item { my @item_ref; my @cart_ref; my ($dbh, $cart_ref, $item_id, $qty, $color) = @_; # If the item isn't already in the cart, look it up from the datab +ase # and store it in the cart as a new entry with a quantity of zero. if (!exists ($cart_ref->{$item_id})) { my $sth = $dbh->prepare ("SELECT item_id, description, categor +y, price, picture, thumbnail, mime_type, color FROM catalog_pet WHERE item_id = ?"); $sth->execute ($item_id); my $item_ref = $sth->fetchrow_arrayref (); $sth->finish (); return if !defined ($item_ref); # this shouldn't happen... @cart_ref->[0] = {}; # create new entry, indexed by item ID @cart_ref->[1] = $item_ref->{description}; @cart_ref->[3] = $item_ref->{price}; @cart_ref->[8] = 1; } @cart_ref->[8] = $qty; @cart_ref->[7] = $color; push (@cart_ref, @item_ref); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Need duplicate item entries in shopping cart
by perrin (Chancellor) on Feb 20, 2003 at 02:07 UTC | |
by b310 (Scribe) on Feb 20, 2003 at 14:32 UTC | |
by perrin (Chancellor) on Feb 20, 2003 at 18:09 UTC |