summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/libraries/Cart.php6
-rw-r--r--user_guide_src/source/changelog.rst1
-rw-r--r--user_guide_src/source/libraries/cart.rst17
3 files changed, 18 insertions, 6 deletions
diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php
index 8a2516f1c..ec67d9b4a 100644
--- a/system/libraries/Cart.php
+++ b/system/libraries/Cart.php
@@ -358,10 +358,8 @@ class CI_Cart {
$items['price'] = (float) $items['price'];
}
- // product name & id shouldn't be changed
- $keys = array_diff($keys, array('id', 'name'));
-
- foreach ($keys as $key)
+ // product id & name shouldn't be changed
+ foreach (array_diff($keys, array('id', 'name')) as $key)
{
$this->_cart_contents[$items['rowid']][$key] = $items[$key];
}
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index b5b31dcc2..76ee7ed31 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -303,6 +303,7 @@ Release Date: Not Released
- Added method ``remove()`` to remove a cart item, updating with quantity of 0 seemed like a hack but has remained to retain compatibility.
- Added method ``get_item()`` to enable retrieving data for a single cart item.
- Added unicode support for product names.
+ - ``update()`` now supports updating all properties attached to an item.
- :doc:`Image Manipulation Library <libraries/image_lib>` changes include:
diff --git a/user_guide_src/source/libraries/cart.rst b/user_guide_src/source/libraries/cart.rst
index 015f1c90e..6d0dd2e3a 100644
--- a/user_guide_src/source/libraries/cart.rst
+++ b/user_guide_src/source/libraries/cart.rst
@@ -88,6 +88,18 @@ array will be stored in the session. However, it is best to standardize
your data among all your products in order to make displaying the
information in a table easier.
+::
+
+ $data = array(
+ 'id' => 'sku_123ABC',
+ 'qty' => 1,
+ 'price' => 39.95,
+ 'name' => 'T-Shirt',
+ 'coupon' => 'XMAS-50OFF'
+ );
+
+ $this->cart->insert($data);
+
The insert() method will return the $rowid if you successfully insert a
single item.
@@ -195,8 +207,8 @@ Updating The Cart
To update the information in your cart, you must pass an array
containing the Row ID and quantity to the $this->cart->update()
function, you may also update any property you have previously
-defined when inserting the item such like (options, price
-or other custom fields you defined).
+defined when inserting the item such as options, price
+or other custom fields you defined.
.. note:: If the quantity is set to zero, the item will be removed from
the cart.
@@ -205,6 +217,7 @@ or other custom fields you defined).
$data = array(
'rowid' => 'b99ccdf16028f015540f341130b6d8ec',
+ 'price' => 10,
'qty' => 3
);