CI_Cart::update PHP Method

update() public method

This function permits the quantity of a given item to be changed. Typically it is called from the "view cart" page if a user makes changes to the quantity before checkout. That array must contain the product ID and quantity for each item.
public update ( $items = [] ) : boolean
return boolean
    public function update($items = array())
    {
        // Was any cart data passed?
        if (!is_array($items) or count($items) === 0) {
            return FALSE;
        }
        // You can either update a single product using a one-dimensional array,
        // or multiple products using a multi-dimensional one.  The way we
        // determine the array type is by looking for a required array key named "rowid".
        // If it's not found we assume it's a multi-dimensional array
        $save_cart = FALSE;
        if (isset($items['rowid'])) {
            if ($this->_update($items) === TRUE) {
                $save_cart = TRUE;
            }
        } else {
            foreach ($items as $val) {
                if (is_array($val) && isset($val['rowid'])) {
                    if ($this->_update($val) === TRUE) {
                        $save_cart = TRUE;
                    }
                }
            }
        }
        // Save the cart data if the insert was successful
        if ($save_cart === TRUE) {
            $this->_save_cart();
            return TRUE;
        }
        return FALSE;
    }