CI_Cart

class CI_Cart

$product_id_rules = '.a-z0-9_-'

These are the regular expression rules that we use to validate the product ID - alpha-numeric, dashes, underscores, or periods by default

$product_name_rules = 'w -.:'

These are the regular expression rules that we use to validate the product ID and product name - alpha-numeric, dashes, underscores, colons or periods by default

$product_name_safe = TRUE

Whether or not to only allow safe product names. Default TRUE.

insert([$items = array()])
Parameters:
  • $items (array) – Items to insert into the cart
Returns:

TRUE on success, FALSE on failure

Return type:

bool

Insert items into the cart and save it to the session table. Returns TRUE on success and FALSE on failure.

update([$items = array()])
Parameters:
  • $items (array) – Items to update in the cart
Returns:

TRUE on success, FALSE on failure

Return type:

bool

This method permits changing the properties of a given item. Typically it is called from the “view cart” page if a user makes changes to the quantity before checkout. That array must contain the rowid for each item.

remove($rowid)
Parameters:
  • $rowid (int) – ID of the item to remove from the cart
Returns:

TRUE on success, FALSE on failure

Return type:

bool

Allows you to remove an item from the shopping cart by passing it the $rowid.

total()
Returns: Total amount
Return type: int

Displays the total amount in the cart.

total_items()
Returns: Total amount of items in the cart
Return type: int

Displays the total number of items in the cart.

contents([$newest_first = FALSE])
Parameters:
  • $newest_first (bool) – Whether to order the array with newest items first
Returns:

An array of cart contents

Return type:

array

Returns an array containing everything in the cart. You can sort the order by which the array is returned by passing it TRUE where the contents will be sorted from newest to oldest, otherwise it is sorted from oldest to newest.

get_item($row_id)
Parameters:
  • $row_id (int) – Row ID to retrieve
Returns:

Array of item data

Return type:

array

Returns an array containing data for the item matching the specified row ID, or FALSE if no such item exists.

has_options($row_id = '')
Parameters:
  • $row_id (int) – Row ID to inspect
Returns:

TRUE if options exist, FALSE otherwise

Return type:

bool

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 method, as shown in the Displaying the Cart example above.

product_options([$row_id = ''])
Parameters:
  • $row_id (int) – Row ID
Returns:

Array of product options

Return type:

array

Returns an array of options for a particular product. This method is designed to be used in a loop with contents(), since you must pass the rowid to this method, as shown in the Displaying the Cart example above.

destroy()
Return type: void

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

doc_CodeIgniter
2016-10-15 16:30:58
Comments
Leave a Comment

Please login to continue.