From 37f4b9caa02783e06dd7c5318200113409a0deb1 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Fri, 1 Jul 2011 17:56:50 -0500 Subject: backed out 648b42a75739, which was a NON-trivial whitespace commit. It broke the Typography class's string replacements, for instance --- user_guide/libraries/cart.html | 46 +++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'user_guide/libraries/cart.html') diff --git a/user_guide/libraries/cart.html b/user_guide/libraries/cart.html index 433bd5089..f084d5dcf 100644 --- a/user_guide/libraries/cart.html +++ b/user_guide/libraries/cart.html @@ -61,13 +61,13 @@ Shopping Cart Class

The Cart Class permits items to be added to a session that stays active while a user is browsing your site. These items can be retrieved and displayed in a standard "shopping cart" format, allowing the user to update the quantity or remove items from the cart.

-

Please note that the Cart Class ONLY provides the core "cart" functionality. It does not provide shipping, credit card authorization, or other processing components.

+

Please note that the Cart Class ONLY provides the core "cart" functionality. It does not provide shipping, credit card authorization, or other processing components.

Initializing the Shopping Cart Class

Important: The Cart class utilizes CodeIgniter's -Session Class to save the cart information to a database, so before using the Cart class you must set up a database table +Session Class to save the cart information to a database, so before using the Cart class you must set up a database table as indicated in the Session Documentation , and set the session preferences in your application/config/config.php file to utilize a database.

To initialize the Shopping Cart Class in your controller constructor, use the $this->load->library function:

@@ -106,19 +106,19 @@ It is intended to be used in cases where your product has options associated wit
  • qty - The quantity being purchased.
  • price - The price of the item.
  • name - The name of the item. -
  • options - Any additional attributes that are needed to identify the product. These must be passed via an array. +
  • options - Any additional attributes that are needed to identify the product. These must be passed via an array. -

    In addition to the five indexes above, there are two reserved words: rowid and subtotal. These are used internally by the Cart class, so +

    In addition to the five indexes above, there are two reserved words: rowid and subtotal. These are used internally by the Cart class, so please do NOT use those words as index names when inserting data into the cart.

    -

    Your array may contain additional data. Anything you include in your array will be stored in the session. However, it is best to standardize your data among +

    Your array may contain additional data. Anything you include in your 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.

    Adding Multiple Items to The Cart

    -

    By using a multi-dimensional array, as shown below, it is possible to add multiple products to the cart in one action. This is useful in cases where you wish to allow +

    By using a multi-dimensional array, as shown below, it is possible to add multiple products to the cart in one action. This is useful in cases where you wish to allow people to select from among several items on the same page.

    @@ -170,10 +170,10 @@ $this->cart->insert($data); <table cellpadding="6" cellspacing="1" style="width:100%" border="0"> <tr> - <th>QTY</th> - <th>Item Description</th> - <th style="text-align:right">Item Price</th> - <th style="text-align:right">Sub-Total</th> + <th>QTY</th> + <th>Item Description</th> + <th style="text-align:right">Item Price</th> + <th style="text-align:right">Sub-Total</th> </tr> <?php $i = 1; ?> @@ -183,8 +183,8 @@ $this->cart->insert($data); <?php echo form_hidden($i.'[rowid]', $items['rowid']); ?> <tr> - <td><?php echo form_input(array('name' => $i.'[qty]', 'value' => $items['qty'], 'maxlength' => '3', 'size' => '5')); ?></td> - <td> + <td><?php echo form_input(array('name' => $i.'[qty]', 'value' => $items['qty'], 'maxlength' => '3', 'size' => '5')); ?></td> + <td> <?php echo $items['name']; ?> <?php if ($this->cart->has_options($items['rowid']) == TRUE): ?> @@ -199,9 +199,9 @@ $this->cart->insert($data); <?php endif; ?> - </td> - <td style="text-align:right"><?php echo $this->cart->format_number($items['price']); ?></td> - <td style="text-align:right">$<?php echo $this->cart->format_number($items['subtotal']); ?></td> + </td> + <td style="text-align:right"><?php echo $this->cart->format_number($items['price']); ?></td> + <td style="text-align:right">$<?php echo $this->cart->format_number($items['subtotal']); ?></td> </tr> <?php $i++; ?> @@ -209,9 +209,9 @@ $this->cart->insert($data); <?php endforeach; ?> <tr> - <td colspan="2"> </td> - <td class="right"><strong>Total</strong></td> - <td class="right">$<?php echo $this->cart->format_number($this->cart->total()); ?></td> + <td colspan="2"> </td> + <td class="right"><strong>Total</strong></td> + <td class="right">$<?php echo $this->cart->format_number($this->cart->total()); ?></td> </tr> </table> @@ -265,11 +265,11 @@ $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 +

    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 +

    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 @@ -311,7 +311,7 @@ function when the update form is submitted. Please examine the construction of t

    $this->cart->has_options(rowid);

    -

    Returns TRUE (boolean) if a particular row in the cart contains options. This function is designed to be used in a loop with $this->cart->contents(), since you must pass the rowid to this function, as shown in the Displaying the Cart example above.

    +

    Returns TRUE (boolean) if a particular row in the cart contains options. This function is designed to be used in a loop with $this->cart->contents(), since you must pass the rowid to this function, as shown in the Displaying the Cart example above.

    $this->cart->product_options(rowid);

    @@ -322,7 +322,7 @@ function when the update form is submitted. Please examine the construction of t

    $this->cart->destroy();

    -

    Permits you to destroy the cart. This function will likely be called when you are finished processing the customer's order.

    +

    Permits you to destroy the cart. This function will likely be called when you are finished processing the customer's order.

    -- cgit v1.2.3-24-g4f1b From 909105135439ac2ade75a99922f77c038e882fee Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Wed, 20 Jul 2011 10:07:40 -0600 Subject: Changed Cart library to return the if inserted successfully. This will be fine for anyone using () == true. http://codeigniter.uservoice.com/forums/40508-codeigniter-reactor/suggestions/2055829-last-rowid-of-cart --- user_guide/libraries/cart.html | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'user_guide/libraries/cart.html') diff --git a/user_guide/libraries/cart.html b/user_guide/libraries/cart.html index f084d5dcf..81b43e363 100644 --- a/user_guide/libraries/cart.html +++ b/user_guide/libraries/cart.html @@ -61,7 +61,7 @@ Shopping Cart Class

    The Cart Class permits items to be added to a session that stays active while a user is browsing your site. These items can be retrieved and displayed in a standard "shopping cart" format, allowing the user to update the quantity or remove items from the cart.

    -

    Please note that the Cart Class ONLY provides the core "cart" functionality. It does not provide shipping, credit card authorization, or other processing components.

    +

    Please note that the Cart Class ONLY provides the core "cart" functionality. It does not provide shipping, credit card authorization, or other processing components.

    Initializing the Shopping Cart Class

    @@ -106,20 +106,19 @@ It is intended to be used in cases where your product has options associated wit
  • qty - The quantity being purchased.
  • price - The price of the item.
  • name - The name of the item. -
  • options - Any additional attributes that are needed to identify the product. These must be passed via an array. +
  • options - Any additional attributes that are needed to identify the product. These must be passed via an array. -

    In addition to the five indexes above, there are two reserved words: rowid and subtotal. These are used internally by the Cart class, so -please do NOT use those words as index names when inserting data into the cart.

    +

    In addition to the five indexes above, there are two reserved words: rowid and subtotal. These are used internally by the Cart class, so please do NOT use those words as index names when inserting data into the cart.

    -

    Your array may contain additional data. Anything you include in your 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.

    +

    Your array may contain additional data. Anything you include in your 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.

    + +

    The insert() method will return the $rowid if you successfully insert a single item.

    Adding Multiple Items to The Cart

    -

    By using a multi-dimensional array, as shown below, it is possible to add multiple products to the cart in one action. This is useful in cases where you wish to allow -people to select from among several items on the same page.

    +

    By using a multi-dimensional array, as shown below, it is possible to add multiple products to the cart in one action. This is useful in cases where you wish to allow people to select from among several items on the same page.

    @@ -265,11 +264,11 @@ $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 +

    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 +

    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 @@ -311,7 +310,7 @@ function when the update form is submitted. Please examine the construction of t

    $this->cart->has_options(rowid);

    -

    Returns TRUE (boolean) if a particular row in the cart contains options. This function is designed to be used in a loop with $this->cart->contents(), since you must pass the rowid to this function, as shown in the Displaying the Cart example above.

    +

    Returns TRUE (boolean) if a particular row in the cart contains options. This function is designed to be used in a loop with $this->cart->contents(), since you must pass the rowid to this function, as shown in the Displaying the Cart example above.

    $this->cart->product_options(rowid);

    @@ -322,7 +321,7 @@ function when the update form is submitted. Please examine the construction of t

    $this->cart->destroy();

    -

    Permits you to destroy the cart. This function will likely be called when you are finished processing the customer's order.

    +

    Permits you to destroy the cart. This function will likely be called when you are finished processing the customer's order.

    -- cgit v1.2.3-24-g4f1b