From 0bd390c660290b7dc478955da6a8a7fbb3ca9fd6 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 13 Feb 2014 14:26:50 +0200 Subject: [ci skip] Polish changes from #2874 --- user_guide_src/source/changelog.rst | 6 +- user_guide_src/source/libraries/cart.rst | 125 +++++++++++++++---------------- 2 files changed, 65 insertions(+), 66 deletions(-) (limited to 'user_guide_src') diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index c8cbbb9e5..029bf61cb 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -303,12 +303,12 @@ Release Date: Not Released - :doc:`Cart Library ` changes include: - - ``insert()`` now auto-increments quantity for an item when inserted twice instead of resetting it, this is the default behaviour of large e-commerce sites. - - *Product Name* strictness can be disabled by switching the ``$product_name_safe`` property to FALSE. - 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. + - Added support for disabling product name strictness via the ``$product_name_safe`` property. + - Changed ``insert()`` method to auto-increment quantity for an item when inserted twice instead of resetting it. + - Changed ``update()`` method to support updating all properties attached to an item. - :doc:`Image Manipulation Library ` changes include: diff --git a/user_guide_src/source/libraries/cart.rst b/user_guide_src/source/libraries/cart.rst index 74e791554..8a473b49d 100644 --- a/user_guide_src/source/libraries/cart.rst +++ b/user_guide_src/source/libraries/cart.rst @@ -33,7 +33,7 @@ Initializing the Shopping Cart Class utilize a database. To initialize the Shopping Cart Class in your controller constructor, -use the $this->load->library function:: +use the ``$this->load->library()`` method:: $this->load->library('cart'); @@ -49,16 +49,16 @@ Adding an Item to The Cart ========================== To add an item to the shopping cart, simply pass an array with the -product information to the $this->cart->insert() function, as shown +product information to the ``$this->cart->insert()`` method, as shown below:: $data = array( - 'id' => 'sku_123ABC', - 'qty' => 1, - 'price' => 39.95, - 'name' => 'T-Shirt', - 'options' => array('Size' => 'L', 'Color' => 'Red') - ); + 'id' => 'sku_123ABC', + 'qty' => 1, + 'price' => 39.95, + 'name' => 'T-Shirt', + 'options' => array('Size' => 'L', 'Color' => 'Red') + ); $this->cart->insert($data); @@ -91,16 +91,16 @@ information in a table easier. :: $data = array( - 'id' => 'sku_123ABC', - 'qty' => 1, - 'price' => 39.95, - 'name' => 'T-Shirt', - 'coupon' => 'XMAS-50OFF' - ); + '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 +The ``insert()`` method will return the $rowid if you successfully insert a single item. Adding Multiple Items to The Cart @@ -148,15 +148,15 @@ helper `. :: - + - - - - + + + + @@ -166,9 +166,9 @@ helper `. - - + - - + + + @@ -192,9 +192,9 @@ helper `. - - - + + +
QTYItem DescriptionItem PriceSub-TotalQTYItem DescriptionItem PriceSub-Total
$i.'[qty]', 'value' => $items['qty'], 'maxlength' => '3', 'size' => '5')); ?> - + $i.'[qty]', 'value' => $items['qty'], 'maxlength' => '3', 'size' => '5')); ?> + cart->has_options($items['rowid']) == TRUE): ?> @@ -182,9 +182,9 @@ helper `. - cart->format_number($items['price']); ?>$cart->format_number($items['subtotal']); ?>cart->format_number($items['price']); ?>$cart->format_number($items['subtotal']); ?>
 Total$cart->format_number($this->cart->total()); ?> Total$cart->format_number($this->cart->total()); ?>
@@ -205,8 +205,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. +containing the Row ID and quantity to the ``$this->cart->update()`` +method:: .. note:: If the quantity is set to zero, the item will be removed from the cart. @@ -214,53 +214,52 @@ function. :: $data = array( - 'rowid' => 'b99ccdf16028f015540f341130b6d8ec', - 'qty' => 3 - ); + '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 - ) - ); + array( + 'rowid' => 'b99ccdf16028f015540f341130b6d8ec', + 'qty' => 3 + ), + array( + 'rowid' => 'xw82g9q3r495893iajdh473990rikw23', + 'qty' => 4 + ), + array( + 'rowid' => 'fh4kdkkkaoe30njgoe92rkdkkobec333', + 'qty' => 2 + ) + ); $this->cart->update($data); -You may also update any property you have previously -defined when inserting the item such as options, price -or other custom fields you defined. +You may also update any property you have previously defined when +inserting the item such as options, price or other custom fields. :: $data = array( - 'rowid' => 'b99ccdf16028f015540f341130b6d8ec', - 'qty' => 1, - 'price' => 49.95, - 'coupon' => NULL - ); + 'rowid' => 'b99ccdf16028f015540f341130b6d8ec', + 'qty' => 1, + 'price' => 49.95, + 'coupon' => NULL + ); $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. +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 @@ -274,9 +273,9 @@ 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 than 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. +field, and making sure it gets passed to the ``update()`` method when +the update form is submitted. Please examine the construction of the +"view cart" page above for more information. *************** @@ -374,7 +373,7 @@ Class Reference Returns TRUE (boolean) if a particular row in the cart contains options. This method is designed to be used in a loop with ``contents()``, since - you must pass the rowid to this function, as shown in the Displaying + you must pass the rowid to this method, as shown in the Displaying the Cart example above. .. method:: product_options([$row_id = '']) -- cgit v1.2.3-24-g4f1b