protected function _update($items = array())
{
// Without these array indexes there is nothing we can do
if (!isset($items['rowid'], $this->_cart_contents[$items['rowid']])) {
return FALSE;
}
// Prep the quantity
if (isset($items['qty'])) {
$items['qty'] = (double) $items['qty'];
// Is the quantity zero? If so we will remove the item from the cart.
// If the quantity is greater than zero we are updating
if ($items['qty'] == 0) {
unset($this->_cart_contents[$items['rowid']]);
return TRUE;
}
}
// find updatable keys
$keys = array_intersect(array_keys($this->_cart_contents[$items['rowid']]), array_keys($items));
// if a price was passed, make sure it contains valid data
if (isset($items['price'])) {
$items['price'] = (double) $items['price'];
}
// product id & name shouldn't be changed
foreach (array_diff($keys, array('id', 'name')) as $key) {
$this->_cart_contents[$items['rowid']][$key] = $items[$key];
}
return TRUE;
}