summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/libraries/Cart.php17
-rw-r--r--user_guide_src/source/libraries/cart.rst10
2 files changed, 20 insertions, 7 deletions
diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php
index b00ccd862..f5e85b715 100644
--- a/system/libraries/Cart.php
+++ b/system/libraries/Cart.php
@@ -323,10 +323,10 @@ class CI_Cart {
/**
* Update the cart
*
- * This function permits the quantity of a given item to be changed.
+ * 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
- * product ID and quantity for each item.
+ * rowid and qty for each item.
*
* @param array
* @return bool
@@ -352,7 +352,18 @@ class CI_Cart {
{
// find updatable keys
$keys = array_intersect(array_keys($this->_cart_contents[$items['rowid']]), array_keys($items));
- foreach ( $keys as $key ) {
+ // if a price was passed, make sure it contains valid data
+ if (isset($keys['price']))
+ {
+ $keys['price'] = (float) $keys['price'];
+ }
+
+ // product name & id shouldn't be changed
+ unset($keys['name']);
+ unset($keys['id']);
+
+ foreach ($keys as $key)
+ {
$this->_cart_contents[$items['rowid']][$key] = $items[$key];
}
}
diff --git a/user_guide_src/source/libraries/cart.rst b/user_guide_src/source/libraries/cart.rst
index fb92c280a..015f1c90e 100644
--- a/user_guide_src/source/libraries/cart.rst
+++ b/user_guide_src/source/libraries/cart.rst
@@ -194,7 +194,9 @@ Updating The Cart
To update the information in your cart, you must pass an array
containing the Row ID and quantity to the $this->cart->update()
-function:
+function, you may also update any property you have previously
+defined when inserting the item such like (options, price
+or other custom fields you defined).
.. note:: If the quantity is set to zero, the item will be removed from
the cart.
@@ -289,10 +291,10 @@ Class Reference
:returns: TRUE on success, FALSE on failure
:rtype: bool
- This method permits the quantity of a given item to be changed.
+ This method permits changing the properties of a given item.
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.
+ to the quantity before checkout. That array must contain the rowid
+ and qty for each item.
.. method:: remove($rowid)