here is a very simple cart in sessions. you have stockno and quan, it can be
easily modified to handle various other variables.

<?php

 class cart
 {

  function add($product_id, $product_quan = 1)
  {
   if ($product_quan < 1)
    $product_quan = 1;

   $this->cart_product_id[$product_id]  = $product_id;
   $this->cart_product_quan[$product_id] = $product_quan;
  }

  function add_single($var_name)
  {
   if ( !isset($GLOBALS[$var_name]) )
    return ;

   $this->add($GLOBALS[$var_name], 1);
  }

  function add_multiple($var_name)
  {
   if ( !isset($GLOBALS[$var_name]) )
    return ;

   foreach($GLOBALS[$var_name] as $pos => $val)
    $this->add($pos, $quan);
  }

  function delete($product_id)
  {
   unset($this->cart_product_id[$product_id]);
   unset($this->cart_product_quan[$product_id]);

   if ( !count($this->cart_product_id) )
   {
    unset($this->cart_product_id);
    unset($this->cart_product_quan);
   }
  }

  function delete_multiple($var_name)
  {
   if ( !isset($GLOBALS[$var_name]) )
    return ;

   foreach($GLOBALS[$var_name] as $pos => $val)
    $this->delete($pos);
  }

  function update($product_id, $product_quan)
  {
   if ($product_quan < 1)
    $product_quan = 1;

   $this->cart_product_id[$product_id]  = $product_id;
   $this->cart_product_quan[$product_id] = $product_quan;
  }

  function update_multiple($var_name)
  {
   if ( !isset($GLOBALS[$var_name]) )
    return ;

   foreach ($GLOBALS[$var_name] as $pos => $val)
    $this->update($pos, $val);
  }
 }

 $cart = new cart;

 if (!isset($HTTP_SESSION_VARS['cart']))
 {
  $cart = new cart();
  session_register('cart');
 }
?>


--


Chris Lee
Mediawaveonline.com

em. [EMAIL PROTECTED]

ph. 250.377.1095
ph. 250.376.2690
fx. 250.554.1120


"Gary" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Chris Lee wrote:
>
> > are you using a spec cart system? or did you write your own? its hard to
> > give an accurate answer without knowing. Ive wrote my own simple cart,
using
> > sessions, to delete an item I just unset the variable.
> >
> > unset($stockno['1234']);
> >
> > where $stockno is an session array variable. its very spec on what
software
> > your using.
> >
> >
> > --
> >
> >
> > Chris Lee
> > Mediawaveonline.com
> >
> > em. [EMAIL PROTECTED]
> >
> > ph. 250.377.1095
> > ph. 250.376.2690
> > fx. 250.554.1120
> >
> >
> >
> >
> > "Gary" <[EMAIL PROTECTED]> wrote in message
> > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> >
> >> Hi All,
> >>   It is Friday afternoon here and I don't want to have to reinvent the
> >> wheel. What would be the easiest way to delete an item from a shopping
> >> cart? I know what is required for Mysql but I am stumped on how to
> >> implement it.
> >>
> >> TIA
> >> Gary
> >>
> >>
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >> To contact the list administrators, e-mail:
[EMAIL PROTECTED]
> >>
>
> I am writing my own system. It is using cookies to give a temp id
> number. When you choose something from the menu it uses the stock number
> to generate a description and cart page. I was thinking about using the
> stock number with a db query to delete the row. I am not sure about the
> best way to accomplish this.
>
> Gary
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to