summaryrefslogtreecommitdiffstats
path: root/system/libraries
diff options
context:
space:
mode:
authorMarcosCoelho <marcos@marcoscoelho.com>2011-07-18 21:12:47 +0200
committerPhil Sturgeon <email@philsturgeon.co.uk>2011-08-13 19:19:29 +0200
commit72038ba6fd2e8196623bf1bd1a38756ad41ce905 (patch)
tree76135ff8e6f81e1cb2236be8515e890f788cb3e7 /system/libraries
parent5025929d76172efd6dd3a7b0f4da7611a3df9391 (diff)
sync total items count and total amount price; by sum of quantity of each item in cart
Diffstat (limited to 'system/libraries')
-rw-r--r--system/libraries/Cart.php4
1 files changed, 3 insertions, 1 deletions
diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php
index 7f65b48b9..b2eaa9ad7 100644
--- a/system/libraries/Cart.php
+++ b/system/libraries/Cart.php
@@ -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