summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/libraries/Cart.php24
-rw-r--r--user_guide_src/source/changelog.rst6
-rw-r--r--user_guide_src/source/libraries/cart.rst5
3 files changed, 32 insertions, 3 deletions
diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php
index e78ecd5f6..7f6cdf5dd 100644
--- a/system/libraries/Cart.php
+++ b/system/libraries/Cart.php
@@ -450,7 +450,29 @@ class CI_Cart {
{
return $this->_cart_contents['cart_total'];
}
-
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Remove Item
+ *
+ * Removes an item from the cart
+ *
+ * @access public
+ * @return boolean
+ */
+ public function remove($rowid)
+ {
+ // just do an unset
+ unset($this->_cart_contents[$rowid]);
+
+ // we need to save the cart now we've made our changes
+ $this->_save_cart();
+
+ // completed
+ return true;
+ }
+
// --------------------------------------------------------------------
/**
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index eda64e7ff..72b7f7e8a 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -47,8 +47,10 @@ Release Date: Not Released
- CI_Loader::_ci_autoloader() is now a protected method.
- Modified valid_ip() to use PHP's filter_var() when possible (>= PHP 5.2) in the :doc:`Form Validation library <libraries/form_validation>`.
- Added custom filename to Email::attach() as $this->email->attach($filename, $disposition, $newname)
- - The Cart library now auto-increments quantity's instead of just resetting it, this is the default behaviour of large e-commerce sites.
- - Cart Product Name strictness can be disabled via the Cart Library by switching "$product_name_safe"
+ - Cart library changes include;
+ - It now auto-increments quantity's instead of just resetting it, this is the default behaviour of large e-commerce sites.
+ - Product Name strictness can be disabled via the Cart Library by switching "$product_name_safe"
+ - Added function remove() to remove a cart item, updating with quantity of 0 seemed like a hack but has remained to retain compatability
- Core
diff --git a/user_guide_src/source/libraries/cart.rst b/user_guide_src/source/libraries/cart.rst
index a1e042ef2..fbf777884 100644
--- a/user_guide_src/source/libraries/cart.rst
+++ b/user_guide_src/source/libraries/cart.rst
@@ -256,6 +256,11 @@ $this->cart->update();
Permits you to update items in the shopping cart, as outlined above.
+$this->cart->remove(rowid);
+**********************
+
+Allows you to remove an item from the shopping cart by passing it the rowid.
+
$this->cart->total();
*********************