summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-10-25 16:29:52 +0200
committerAndrey Andreev <narf@bofh.bg>2012-10-25 16:29:52 +0200
commitcdeee661db2438cc65304f704ab4bcebeccb9b7d (patch)
treeaff34eb215aafd608a6a78aca079f67d0b828529 /system
parent60b97145a0cb1c3bba35ec68be7eae911b2b331c (diff)
Add CI_Cart::get_item() (rel #400)
Diffstat (limited to 'system')
-rw-r--r--system/libraries/Cart.php29
1 files changed, 23 insertions, 6 deletions
diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php
index c442f88da..d4b17fa36 100644
--- a/system/libraries/Cart.php
+++ b/system/libraries/Cart.php
@@ -480,17 +480,34 @@ class CI_Cart {
// --------------------------------------------------------------------
/**
+ * Get cart item
+ *
+ * Returns the details of a specific item in the cart
+ *
+ * @param string $row_id
+ * @return array
+ */
+ public function get_item($row_id)
+ {
+ return (in_array($row_id, array('total_items', 'cart_total'), TRUE) OR ! isset($this->_cart_contents[$row_id]))
+ ? FALSE
+ : $this->_cart_contents[$row_id];
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Has options
*
* Returns TRUE if the rowid passed to this function correlates to an item
* that has options associated with it.
*
- * @param mixed
+ * @param string $row_id = ''
* @return bool
*/
- public function has_options($rowid = '')
+ public function has_options($row_id = '')
{
- return (isset($this->_cart_contents[$rowid]['options']) && count($this->_cart_contents[$rowid]['options']) !== 0);
+ return (isset($this->_cart_contents[$row_id]['options']) && count($this->_cart_contents[$row_id]['options']) !== 0);
}
// --------------------------------------------------------------------
@@ -500,12 +517,12 @@ class CI_Cart {
*
* Returns the an array of options, for a particular product row ID
*
- * @param int
+ * @param string $row_id = ''
* @return array
*/
- public function product_options($rowid = '')
+ public function product_options($row_id = '')
{
- return isset($this->_cart_contents[$rowid]['options']) ? $this->_cart_contents[$rowid]['options'] : array();
+ return isset($this->_cart_contents[$row_id]['options']) ? $this->_cart_contents[$row_id]['options'] : array();
}
// --------------------------------------------------------------------