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

Closed
wants to merge 3 commits into
from
View
@@ -543,8 +543,27 @@ function destroy()
$this->CI->session->unset_userdata('cart_contents');
}
-
-
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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
@@ -97,6 +97,7 @@ <h2>Version 2.1.0 (planned)</h2>
<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>
</ul>
</li>
<li>Core
@@ -308,6 +308,10 @@ <h2>$this->cart->contents();</h2>
<p>Returns an array containing everything in the cart.</p>
+<h2>$this->cart->item(rowid);</h2>
+
+<p>Returns an array containing the details of a specific item in the cart.</p>
+
<h2>$this->cart->has_options(rowid);</h2>