summaryrefslogtreecommitdiffstats
path: root/system/libraries/Cart.php
diff options
context:
space:
mode:
authorAndrew Seymour <commit@andrewseymour.co.uk>2011-12-13 17:44:59 +0100
committerAndrew Seymour <commit@andrewseymour.co.uk>2011-12-13 17:44:59 +0100
commitde2e96a298cc48b8e86a03d530bc328bd43b0c80 (patch)
tree23606bb70eb3872635aa1f195e9073241a636b39 /system/libraries/Cart.php
parentfefff9fcdfc26676b8c57653c3d8176b729901b2 (diff)
Added the ability to get the contents in a different order
Diffstat (limited to 'system/libraries/Cart.php')
-rw-r--r--system/libraries/Cart.php12
1 files changed, 10 insertions, 2 deletions
diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php
index 997b9b8de..2e580863b 100644
--- a/system/libraries/Cart.php
+++ b/system/libraries/Cart.php
@@ -476,9 +476,17 @@ class CI_Cart {
* @access public
* @return array
*/
- function contents()
+ function contents($newest_first = false)
{
- $cart = $this->_cart_contents;
+ // do we want the newest first?
+ if($newest_first)
+ {
+ // reverse the array
+ $cart = array_reverse($this->_cart_contents);
+ } else {
+ // just added first to last
+ $cart = $this->_cast_contents;
+ }
// Remove these so they don't create a problem when showing the cart table
unset($cart['total_items']);