Properties

$product_id_rules

$product_id_rules : string

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

Type

string

$product_name_rules

$product_name_rules : string

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

Type

string

$product_name_safe

$product_name_safe : boolean

only allow safe product names

Type

boolean

$CI

$CI : object

Reference to CodeIgniter instance

Type

object

$_cart_contents

$_cart_contents : array

Contents of the cart

Type

array

Methods

__construct()

__construct(  $params = array()) : void

Shopping Class Constructor

The constructor loads the Session class, used to store the shopping cart contents.

Parameters

$params

insert()

insert(  $items = array()) : boolean

Insert items into the cart and save it to the session table

Parameters

$items

Returns

boolean

update()

update(  $items = array()) : boolean

Update the cart

This function permits the quantity of a given item to be changed. Typically it is called from the "view cart" page if a user makes changes to the quantity before checkout. That array must contain the product ID and quantity for each item.

Parameters

$items

Returns

boolean

total()

total() : integer

Cart Total

Returns

integer

remove()

remove(  $rowid) : boolean

Remove Item

Removes an item from the cart

Parameters

$rowid

Returns

boolean

total_items()

total_items() : integer

Total Items

Returns the total item count

Returns

integer

contents()

contents(  $newest_first = FALSE) : array

Cart Contents

Returns the entire cart array

Parameters

$newest_first

Returns

array

get_item()

get_item(string  $row_id) : array

Get cart item

Returns the details of a specific item in the cart

Parameters

string $row_id

Returns

array

has_options()

has_options(string  $row_id = '') : boolean

Has options

Returns TRUE if the rowid passed to this function correlates to an item that has options associated with it.

Parameters

string $row_id

= ''

Returns

boolean

product_options()

product_options(string  $row_id = '') : array

Product options

Returns the an array of options, for a particular product row ID

Parameters

string $row_id

= ''

Returns

array

format_number()

format_number(  $n = '') : string

Format Number

Returns the supplied number with commas and a decimal point.

Parameters

$n

Returns

string

destroy()

destroy() : void

Destroy the cart

Empties the cart and kills the session

_insert()

_insert(  $items = array()) : boolean

Insert

Parameters

$items

Returns

boolean

_update()

_update(  $items = array()) : boolean

Update the cart

This function permits changing item properties. 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 and quantity for each item.

Parameters

$items

Returns

boolean

_save_cart()

_save_cart() : boolean

Save the cart array to the session DB

Returns

boolean