PHP Class Cart\Cart

Datei anzeigen Open project: mike182uk/cart Class Usage Examples

Public Methods

Method Description
__construct ( string $id, Cart\Storage\Store $store ) Create a new cart instance.
add ( cart\CartItem $cartItem ) Add an item to the cart.
all ( ) : cart\CartItem[] Retrieve all of the items in the cart.
clear ( ) Remove all items from the cart.
find ( string $itemId ) : cart\CartItem | null Find an item in the cart.
get ( string $itemId ) : cart\CartItem | null Retrieve an item from the cart by its id.
getId ( ) : string Retrieve the cart id.
getStore ( ) : Cart\Storage\Store Retrieve the cart storage implementation.
has ( string $itemId ) : boolean Determine if an item exists in the cart.
remove ( string $itemId ) Remove an item from the cart.
restore ( ) Restore the cart from its saved state.
save ( ) Save the cart state.
tax ( ) : float Get the cart tax.
toArray ( ) : array Export the cart as an array.
total ( ) : float Get the cart total including tax.
totalExcludingTax ( ) : float Get the cart total excluding tax.
totalItems ( ) : integer Get the total number of items in the cart.
totalUniqueItems ( ) : integer Get the total number of unique items in the cart.
update ( string $itemId, string $key, mixed $value ) : string Update an item in the cart.

Private Methods

Method Description
restoreCheckContents ( array $data ) Check the contents of the data to be restored contains the correct data.
restoreCheckContentsType ( array $data ) Check the contents of the data to be restored is of the correct type.
restoreCheckType ( mixed $data ) Check the data to be restored is of the correct type.

Method Details

__construct() public method

Create a new cart instance.
public __construct ( string $id, Cart\Storage\Store $store )
$id string
$store Cart\Storage\Store

add() public method

Add an item to the cart.
public add ( cart\CartItem $cartItem )
$cartItem cart\CartItem

all() public method

Retrieve all of the items in the cart.
public all ( ) : cart\CartItem[]
return cart\CartItem[]

clear() public method

Remove all items from the cart.
public clear ( )

find() public method

Find an item in the cart.
public find ( string $itemId ) : cart\CartItem | null
$itemId string
return cart\CartItem | null

get() public method

Retrieve an item from the cart by its id.
public get ( string $itemId ) : cart\CartItem | null
$itemId string
return cart\CartItem | null

getId() public method

Retrieve the cart id.
public getId ( ) : string
return string

getStore() public method

Retrieve the cart storage implementation.
public getStore ( ) : Cart\Storage\Store
return Cart\Storage\Store

has() public method

Determine if an item exists in the cart.
public has ( string $itemId ) : boolean
$itemId string
return boolean

remove() public method

Remove an item from the cart.
public remove ( string $itemId )
$itemId string

restore() public method

Restore the cart from its saved state.
public restore ( )

save() public method

Save the cart state.
public save ( )

tax() public method

Get the cart tax.
public tax ( ) : float
return float

toArray() public method

Export the cart as an array.
public toArray ( ) : array
return array

total() public method

Get the cart total including tax.
public total ( ) : float
return float

totalExcludingTax() public method

Get the cart total excluding tax.
public totalExcludingTax ( ) : float
return float

totalItems() public method

Get the total number of items in the cart.
public totalItems ( ) : integer
return integer

totalUniqueItems() public method

Get the total number of unique items in the cart.
public totalUniqueItems ( ) : integer
return integer

update() public method

Update an item in the cart.
public update ( string $itemId, string $key, mixed $value ) : string
$itemId string
$key string
$value mixed
return string