bphein1980
07-07-2007, 09:00 AM
I am using the webforcecart.com (http://webforcecart.com) shopping cart.
The items that I add to the cart can be the same item with different variables. For example, T-Shirt can come in blue, red, white. So, if buy a blue one and a red one, the cart will display them seperately (normal functionality of a shopping cart).
My problem is that when I am removing items from the cart, I am identifying them in the array by their ID... so when I remove one, it's actually removing all occurances of that ID (so both the blue and red one get removed, even though I only wanted to remove the red one). That's the basics, there are actually 6 different item options that come into play.
line1, line2, line3, line4, font_style, icon --- they are stored in an array called $iteminfo.
So, I need the cart to remove only the item where the product i tell it to remove matches those 6 options.
The current delete function is this:
function del_item($itemid){ // removes an item from cart
$ti = array();
$this->itemqtys[$itemid] = 0;
foreach($this->items as $item){
if($item != $itemid){
$ti[] = $item;
}
}
$this->items = $ti;
$this->_update_total();
} //end of del_item
All the product info is being stored in these arrays:
var $total = 0;
var $itemcount = 0;
var $items = array();
var $itemprices = array();
var $itemnames = array();
var $itemqtys = array();
var $iteminfo = array();
I'm trying to extend the functionality of webforcecart (http://webforcecart.com/). I think if I can figure out how to complete the delete function to work the way I need it, I can figure out the other functions for updating the cart.
Thanks for any input or help you can provide.
The items that I add to the cart can be the same item with different variables. For example, T-Shirt can come in blue, red, white. So, if buy a blue one and a red one, the cart will display them seperately (normal functionality of a shopping cart).
My problem is that when I am removing items from the cart, I am identifying them in the array by their ID... so when I remove one, it's actually removing all occurances of that ID (so both the blue and red one get removed, even though I only wanted to remove the red one). That's the basics, there are actually 6 different item options that come into play.
line1, line2, line3, line4, font_style, icon --- they are stored in an array called $iteminfo.
So, I need the cart to remove only the item where the product i tell it to remove matches those 6 options.
The current delete function is this:
function del_item($itemid){ // removes an item from cart
$ti = array();
$this->itemqtys[$itemid] = 0;
foreach($this->items as $item){
if($item != $itemid){
$ti[] = $item;
}
}
$this->items = $ti;
$this->_update_total();
} //end of del_item
All the product info is being stored in these arrays:
var $total = 0;
var $itemcount = 0;
var $items = array();
var $itemprices = array();
var $itemnames = array();
var $itemqtys = array();
var $iteminfo = array();
I'm trying to extend the functionality of webforcecart (http://webforcecart.com/). I think if I can figure out how to complete the delete function to work the way I need it, I can figure out the other functions for updating the cart.
Thanks for any input or help you can provide.