diff options
author | Rick Ellis <rick.ellis@ellislab.com> | 2009-02-24 23:04:25 +0100 |
---|---|---|
committer | Rick Ellis <rick.ellis@ellislab.com> | 2009-02-24 23:04:25 +0100 |
commit | a34a2b2c6761e7a331934f948db6b334a6316cd0 (patch) | |
tree | 0fc844a04737b27aa2723502e068dffe1d01b6ff | |
parent | 3c11b6f5dee83ebe11dfdcec3022313c45a4a4e2 (diff) |
Updated the "update cart" information, as it was incorrect.
-rw-r--r-- | user_guide/libraries/cart.html | 150 |
1 files changed, 58 insertions, 92 deletions
diff --git a/user_guide/libraries/cart.html b/user_guide/libraries/cart.html index 4649c5dda..d63be495f 100644 --- a/user_guide/libraries/cart.html +++ b/user_guide/libraries/cart.html @@ -155,98 +155,6 @@ $this->cart->insert($data); </code>
-<h2>Updating The Cart</h2>
-
-<p>To update the information in your cart, pass an array containing the product ID and quantity to the <dfn>$this->cart->update()</dfn> function:</p>
-
-
-<code>
-$data = array(<br />
- 'id' => '123XYZ',<br />
- 'qty' => 3<br />
- );<br />
-<br />
-
-$this->cart->update($data);
-
-</code>
-
-<p>Just as you can when inserting, you may use a multi-dimensional array in order to update multiple items simultaneously:</p>
-
-
-<code>
-$data = array(<br />
-
- array(<br />
- 'id' => 'sku_123ABC',<br />
- 'qty' => 3<br />
- ),<br />
-
- array(<br />
- 'id' => 'sku_567ZYX',<br />
- 'qty' => 4<br />
- ),<br />
-
- array(<br />
- 'id' => 'sku_965QRS',<br />
- 'qty' => 2<br />
- )<br />
-
- );<br />
-<br />
-
-$this->cart->update($data);
-
-</code>
-
-
-
-
-<h2>Deleting an Item From The Cart</h2>
-
-<p>To delete an item from your cart, pass an array containing the product ID and a quantity of zero to the <dfn>$this->cart->update()</dfn> function:</p>
-
-
-<code>
-$data = array(<br />
- 'id' => '123XYZ',<br />
- 'qty' => 0<br />
- );<br />
-<br />
-
-$this->cart->update($data);
-
-</code>
-
-
-<p>You may use a multi-dimensional array in order to delete multiple items simultaneously:</p>
-
-
-<code>
-$data = array(<br />
-
- array(<br />
- 'id' => 'sku_123ABC',<br />
- 'qty' => 0<br />
- ),<br />
-
- array(<br />
- 'id' => 'sku_567ZYX',<br />
- 'qty' => 0<br />
- ),<br />
-
- array(<br />
- 'id' => 'sku_965QRS',<br />
- 'qty' => 0<br />
- )<br />
-
- );<br />
-<br />
-
-$this->cart->update($data);
-
-</code>
-
<h2>Displaying the Cart</h2>
@@ -313,6 +221,64 @@ $this->cart->update($data); +
+
+<h2>Updating The Cart</h2>
+
+<p>To update the information in your cart, you must pass an array containing the <kbd>Row ID</kbd> and quantity to the <dfn>$this->cart->update()</dfn> function:</p>
+
+<p class="important"><strong>Note:</strong> If the quantity is set to zero, the item will be removed from the cart.</p>
+
+<code>
+$data = array(<br />
+ 'rowid' => 'b99ccdf16028f015540f341130b6d8ec',<br />
+ 'qty' => 3<br />
+ );<br />
+<br />
+
+$this->cart->update($data);
+<br /><br />
+// Or a multi-dimensional array<br /><br />
+$data = array(<br />
+
+ array(<br />
+ 'rowid' => 'b99ccdf16028f015540f341130b6d8ec',<br />
+ 'qty' => 3<br />
+ ),<br />
+
+ array(<br />
+ 'rowid' => 'xw82g9q3r495893iajdh473990rikw23',<br />
+ 'qty' => 4<br />
+ ),<br />
+
+ array(<br />
+ 'rowid' => 'fh4kdkkkaoe30njgoe92rkdkkobec333',<br />
+ 'qty' => 2<br />
+ )<br />
+
+ );<br />
+<br />
+
+$this->cart->update($data);
+
+
+
+
+</code>
+
+<p><strong>What is a Row ID?</strong> The <kbd>row ID</kbd> is a unique identifier that is generated by the cart code when an item is added to the cart. The reason a
+unique ID is created is so that identical products with different options can be managed by the cart.</p>
+
+<p>For example, let's say someone buys two identical t-shirts (same product ID), but in different sizes. The product ID (and other attributes) will be
+identical for both sizes because it's the same shirt. The only difference will be the size. The cart must therefore have a means of identifying this
+difference so that the two sizes of shirts can be managed independently. It does so by creating a unique "row ID" based on the product ID and any options associated with it.</p>
+
+<p>In nearly all cases, updating the cart will be something the user does via the "view cart" page, so as a developer, it is unlikely that you will ever have to concern yourself
+with the "row ID", other then making sure your "view cart" page contains this information in a hidden form field, and making sure it gets passed to the update
+function when the update form is submitted. Please examine the construction of the "view cart" page above for more information.</p>
+
+
+
<p> <br /></p>
|