Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Fix #400 - No Easy Way to Get Details of Single Item in Cart #400

wants to merge 3 commits into from

3 participants


Added new item() method to the Cart library to allow you to get the details of a specific cart item as an array in one step.

I know the Cart library is probably going to be moved to a Spark, but, I thought this would be a nice thing to have regardless of where it ends up.



@narfbg narfbg referenced this pull request from a commit
@narfbg narfbg Add CI_Cart::get_item() (rel #400) cdeee66

Manually implemented, as this PR is way out of date ... see the above commit.

@narfbg narfbg closed this
@nonchip nonchip referenced this pull request from a commit in nonchip/CodeIgniter
@narfbg narfbg Add CI_Cart::get_item() (rel #400) 346e87f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
23 system/libraries/Cart.php
@@ -543,8 +543,27 @@ function destroy()
+ // --------------------------------------------------------------------
+ /**
+ * Cart Item
+ *
+ * Returns the details of a specific cart item.
+ *
+ * @access public
+ * @param integer ID of the cart item to get details of
+ * @return array
+ */
+ public function item($row_id = FALSE)
+ {
+ if (empty($row_id))
+ {
+ return array();
+ }
+ return $this->_cart_contents[$rowid];
+ }
// END Cart Class
1  user_guide/changelog.html
@@ -97,6 +97,7 @@
<li>Added max_filename_increment config setting for Upload library.</li>
<li><samp>CI_Loader::_ci_autoloader()</samp> is now a protected method.</li>
<li>Added <kbd>is_unique</kbd> to the <a href="libraries/form_validation.html">Form Validation library</a>.</li>
+ <li>New <kdb>$this->cart->item()</kdb> method in the <a href="libraries/cart.html">Cart Library</a> that allows one to get all the details of a specific cart item in an array.</li>
4 user_guide/libraries/cart.html
@@ -308,6 +308,10 @@
<p>Returns an array containing everything in the cart.</p>
+<p>Returns an array containing the details of a specific item in the cart.</p>
Something went wrong with that request. Please try again.