diff options
Diffstat (limited to 'system/libraries/Cart.php')
-rw-r--r-- | system/libraries/Cart.php | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index 7f65b48b9..ab5a70c98 100644 --- a/system/libraries/Cart.php +++ b/system/libraries/Cart.php @@ -99,7 +99,7 @@ class CI_Cart { $save_cart = FALSE; if (isset($items['id'])) { - if ($this->_insert($items) == TRUE) + if (($rowid = $this->_insert($items))) { $save_cart = TRUE; } @@ -110,7 +110,7 @@ class CI_Cart { { if (is_array($val) AND isset($val['id'])) { - if ($this->_insert($val) == TRUE) + if ($this->_insert($val)) { $save_cart = TRUE; } @@ -122,7 +122,7 @@ class CI_Cart { if ($save_cart == TRUE) { $this->_save_cart(); - return TRUE; + return isset($rowid) ? $rowid : TRUE; } return FALSE; @@ -244,7 +244,7 @@ class CI_Cart { } // Woot! - return TRUE; + return $rowid; } // -------------------------------------------------------------------- @@ -374,6 +374,7 @@ class CI_Cart { // Lets add up the individual prices and set the cart sub-total $total = 0; + $items = 0; foreach ($this->_cart_contents as $key => $val) { // We make sure the array contains the proper indexes @@ -383,13 +384,14 @@ class CI_Cart { } $total += ($val['price'] * $val['qty']); + $items += $val['qty']; // Set the subtotal $this->_cart_contents[$key]['subtotal'] = ($this->_cart_contents[$key]['price'] * $this->_cart_contents[$key]['qty']); } // Set the cart total and total items. - $this->_cart_contents['total_items'] = count($this->_cart_contents); + $this->_cart_contents['total_items'] = $items; $this->_cart_contents['cart_total'] = $total; // Is our cart empty? If so we delete it from the session |