summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-02-13 13:16:28 +0100
committerAndrey Andreev <narf@devilix.net>2014-02-13 13:16:28 +0100
commitb297d9c955c9737ed3d42bfb84190b0b7b03905e (patch)
tree64f3e1243f6b87c91a27a3efffbda5a2aa69afe7 /system
parent678606dc0d3b1554a7635354df82346a252b302b (diff)
parent42a1139debbe1679beb670dd29561a2965f99b8c (diff)
Merge branch 'develop' of github.com:EllisLab/CodeIgniter into develop
Diffstat (limited to 'system')
-rw-r--r--system/libraries/Cart.php18
1 files changed, 15 insertions, 3 deletions
diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php
index 5a31a1d45..389b1b77e 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 quantity for each item.
*
* @param array
* @return bool
@@ -350,7 +350,19 @@ class CI_Cart {
}
else
{
- $this->_cart_contents[$items['rowid']]['qty'] = $items['qty'];
+ // 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'] = (float) $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;