PHP Class CI_Cart, TastyIgniter

Author: ExpressionEngine Dev Team
Datei anzeigen Open project: tastyigniter/tastyigniter Class Usage Examples

Public Properties

Property Type Description
$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
$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
$product_name_safe boolean only allow safe product names

Protected Properties

Property Type Description
$CI object Reference to CodeIgniter instance
$_cart_contents array Contents of the cart

Public Methods

Method Description
__construct ( $params = [] ) : void Shopping Class Constructor
contents ( $newest_first = FALSE ) : array Cart Contents
destroy ( ) : void Destroy the cart
format_number ( $n = '' ) : string Format Number
get_item ( string $row_id ) : array Get cart item
has_options ( string $row_id = '' ) : boolean Has options
insert ( $items = [] ) : boolean Insert items into the cart and save it to the session table
product_options ( string $row_id = '' ) : array Product options
remove ( $rowid ) : boolean Remove Item
total ( ) : integer Cart Total
total_items ( ) : integer Total Items
update ( $items = [] ) : boolean Update the cart

Protected Methods

Method Description
_insert ( $items = [] ) : boolean Insert
_save_cart ( ) : boolean Save the cart array to the session DB
_update ( $items = [] ) : boolean Update the cart

Method Details

__construct() public method

The constructor loads the Session class, used to store the shopping cart contents.
public __construct ( $params = [] ) : void
return void

_insert() protected method

Insert
protected _insert ( $items = [] ) : boolean
return boolean

_save_cart() protected method

Save the cart array to the session DB
protected _save_cart ( ) : boolean
return boolean

_update() protected method

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.
protected _update ( $items = [] ) : boolean
return boolean

contents() public method

Returns the entire cart array
public contents ( $newest_first = FALSE ) : array
return array

destroy() public method

Empties the cart and kills the session
public destroy ( ) : void
return void

format_number() public method

Returns the supplied number with commas and a decimal point.
public format_number ( $n = '' ) : string
return string

get_item() public method

Returns the details of a specific item in the cart
public get_item ( string $row_id ) : array
$row_id string
return array

has_options() public method

Returns TRUE if the rowid passed to this function correlates to an item that has options associated with it.
public has_options ( string $row_id = '' ) : boolean
$row_id string = ''
return boolean

insert() public method

Insert items into the cart and save it to the session table
public insert ( $items = [] ) : boolean
return boolean

product_options() public method

Returns the an array of options, for a particular product row ID
public product_options ( string $row_id = '' ) : array
$row_id string = ''
return array

remove() public method

Removes an item from the cart
public remove ( $rowid ) : boolean
return boolean

total() public method

Cart Total
public total ( ) : integer
return integer

total_items() public method

Returns the total item count
public total_items ( ) : integer
return integer

update() public method

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.
public update ( $items = [] ) : boolean
return boolean

Property Details

$CI protected_oe property

Reference to CodeIgniter instance
protected object $CI
return object

$_cart_contents protected_oe property

Contents of the cart
protected array $_cart_contents
return array

$product_id_rules public_oe property

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

$product_name_rules public_oe property

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

$product_name_safe public_oe property

only allow safe product names
public bool $product_name_safe
return boolean