summaryrefslogtreecommitdiffstats
path: root/system/libraries
diff options
context:
space:
mode:
Diffstat (limited to 'system/libraries')
-rw-r--r--system/libraries/Cart.php49
1 files changed, 25 insertions, 24 deletions
diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php
index 5b05974e4..6cc1509b6 100644
--- a/system/libraries/Cart.php
+++ b/system/libraries/Cart.php
@@ -282,10 +282,10 @@ class CI_Cart {
// 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 "id".
+ // 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'], $items['qty']))
+ if (isset($items['rowid']))
{
if ($this->_update($items) === TRUE)
{
@@ -296,7 +296,7 @@ class CI_Cart {
{
foreach ($items as $val)
{
- if (is_array($val) && isset($val['rowid'], $val['qty']))
+ if (is_array($val) && isset($val['rowid']))
{
if ($this->_update($val) === TRUE)
{
@@ -332,37 +332,38 @@ class CI_Cart {
protected function _update($items = array())
{
// Without these array indexes there is nothing we can do
- if ( ! isset($items['qty'], $items['rowid'], $this->_cart_contents[$items['rowid']]))
+ if ( ! isset($items['rowid'], $this->_cart_contents[$items['rowid']]))
{
return FALSE;
}
// Prep the quantity
- $items['qty'] = (float) $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']]);
- }
- else
+ if ( isset($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['qty'] = (float) $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)
{
- $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];
+ 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'] = (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;
}