CI_Cart::_update PHP Method

_update() protected method

This function permits changing item properties. Typically it is called from the "view cart" page if a user makes changes to the quantity before checkout. That array must contain the rowid and quantity for each item.
protected _update ( $items = [] ) : boolean
return boolean
    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;
    }