Added the ability to get the contents in a different order
diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php
index 997b9b8..2e58086 100644
--- a/system/libraries/Cart.php
+++ b/system/libraries/Cart.php
@@ -476,9 +476,17 @@
* @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']);
diff --git a/user_guide_src/source/libraries/cart.rst b/user_guide_src/source/libraries/cart.rst
index 850d7e9..a1e042e 100644
--- a/user_guide_src/source/libraries/cart.rst
+++ b/user_guide_src/source/libraries/cart.rst
@@ -266,10 +266,13 @@
Displays the total number of items in the cart.
-$this->cart->contents();
+$this->cart->contents(boolean);
************************
-Returns an array containing everything in the cart.
+Returns an array containing everything in the cart. You can sort the order,
+by which this is returned by passing it "true" where the contents will be sorted
+from newest to oldest, by leaving this function blank, you'll automatically just get
+first added to the basket to last added to the basket.
$this->cart->has_options(rowid);
*********************************