diff options
author | Ahmad Anbar <aanbar@gmail.com> | 2014-02-13 00:45:27 +0100 |
---|---|---|
committer | Ahmad Anbar <aanbar@gmail.com> | 2014-02-13 00:45:27 +0100 |
commit | 7d16de620a46f84ffeb52a54ae82439a06f89c74 (patch) | |
tree | 1bf9cc21fc8ae04b404b14c68a6248541df6aa2f /system/libraries/Cart.php | |
parent | f69f1822558645aa00944b436558fb6948f42aa9 (diff) |
Fixed code style & added few extra checks.
Updated cart documentation.
Diffstat (limited to 'system/libraries/Cart.php')
-rw-r--r-- | system/libraries/Cart.php | 17 |
1 files changed, 14 insertions, 3 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]; } } |