From a34a2b2c6761e7a331934f948db6b334a6316cd0 Mon Sep 17 00:00:00 2001 From: Rick Ellis Date: Tue, 24 Feb 2009 22:04:25 +0000 Subject: Updated the "update cart" information, as it was incorrect. --- user_guide/libraries/cart.html | 150 ++++++++++++++++------------------------- 1 file changed, 58 insertions(+), 92 deletions(-) (limited to 'user_guide/libraries') 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); -

Updating The Cart

- -

To update the information in your cart, pass an array containing the product ID and quantity to the $this->cart->update() function:

- - - -$data = array(
-               'id'  => '123XYZ',
-               'qty' => 3
-            );
-
- -$this->cart->update($data); - -
- -

Just as you can when inserting, you may use a multi-dimensional array in order to update multiple items simultaneously:

- - - -$data = array(
- -               array(
-                       'id'      => 'sku_123ABC',
-                       'qty'     => 3
-                    ),
- -               array(
-                       'id'      => 'sku_567ZYX',
-                       'qty'     => 4
-                    ),
- -               array(
-                       'id'      => 'sku_965QRS',
-                       'qty'     => 2
-                    )
- -            );
-
- -$this->cart->update($data); - -
- - - - -

Deleting an Item From The Cart

- -

To delete an item from your cart, pass an array containing the product ID and a quantity of zero to the $this->cart->update() function:

- - - -$data = array(
-               'id'  => '123XYZ',
-               'qty' => 0
-            );
-
- -$this->cart->update($data); - -
- - -

You may use a multi-dimensional array in order to delete multiple items simultaneously:

- - - -$data = array(
- -               array(
-                       'id'      => 'sku_123ABC',
-                       'qty'     => 0
-                    ),
- -               array(
-                       'id'      => 'sku_567ZYX',
-                       'qty'     => 0
-                    ),
- -               array(
-                       'id'      => 'sku_965QRS',
-                       'qty'     => 0
-                    )
- -            );
-
- -$this->cart->update($data); - -
-

Displaying the Cart

@@ -313,6 +221,64 @@ $this->cart->update($data); + + +

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:

+ +

Note: If the quantity is set to zero, the item will be removed from the cart.

+ + +$data = array(
+               'rowid' => 'b99ccdf16028f015540f341130b6d8ec',
+               'qty'   => 3
+            );
+
+ +$this->cart->update($data); +

+// Or a multi-dimensional array

+$data = array(
+ +               array(
+                       'rowid'   => 'b99ccdf16028f015540f341130b6d8ec',
+                       'qty'     => 3
+                    ),
+ +               array(
+                       'rowid'   => 'xw82g9q3r495893iajdh473990rikw23',
+                       'qty'     => 4
+                    ),
+ +               array(
+                       'rowid'   => 'fh4kdkkkaoe30njgoe92rkdkkobec333',
+                       'qty'     => 2
+                    )
+ +            );
+
+ +$this->cart->update($data); + + + + +
+ +

What is a Row ID?  The row ID 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.

+ +

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.

+ +

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.

+ + +

 

-- cgit v1.2.3-24-g4f1b