Re: Delete from cart

From: Date: Sat, 17 Feb 2001 00:09:44 +0000
Subject: Re: Delete from cart
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-40265@lists.php.net to get a copy of this message
Thanks Chris, It is a little late in the design to use your class, but it has given me an idea on how to delete from my code. Thanks Gary Chris Lee wrote:
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. lee@mediawaveonline.com ph. 250.377.1095 ph. 250.376.2690 fx. 250.554.1120 "Gary" <deadfred@2sie4.com> wrote in message news:3A8DB138.50003@2sie4.com...
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. lee@mediawaveonline.com ph. 250.377.1095 ph. 250.376.2690 fx. 250.554.1120 "Gary" <deadfred@2sie4.com> wrote in message news:3A8D8B39.4020208@2sie4.com...
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: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail:
php-list-admin@lists.php.net
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: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net


« previous php.general (#40265) next »