PHP Класс Cart\Cart

Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__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.

Приватные методы

Метод Описание
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.

Описание методов

__construct() публичный метод

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

add() публичный метод

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

all() публичный метод

Retrieve all of the items in the cart.
public all ( ) : cart\CartItem[]
Результат cart\CartItem[]

clear() публичный метод

Remove all items from the cart.
public clear ( )

find() публичный метод

Find an item in the cart.
public find ( string $itemId ) : cart\CartItem | null
$itemId string
Результат cart\CartItem | null

get() публичный метод

Retrieve an item from the cart by its id.
public get ( string $itemId ) : cart\CartItem | null
$itemId string
Результат cart\CartItem | null

getId() публичный метод

Retrieve the cart id.
public getId ( ) : string
Результат string

getStore() публичный метод

Retrieve the cart storage implementation.
public getStore ( ) : Cart\Storage\Store
Результат Cart\Storage\Store

has() публичный метод

Determine if an item exists in the cart.
public has ( string $itemId ) : boolean
$itemId string
Результат boolean

remove() публичный метод

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

restore() публичный метод

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

save() публичный метод

Save the cart state.
public save ( )

tax() публичный метод

Get the cart tax.
public tax ( ) : float
Результат float

toArray() публичный метод

Export the cart as an array.
public toArray ( ) : array
Результат array

total() публичный метод

Get the cart total including tax.
public total ( ) : float
Результат float

totalExcludingTax() публичный метод

Get the cart total excluding tax.
public totalExcludingTax ( ) : float
Результат float

totalItems() публичный метод

Get the total number of items in the cart.
public totalItems ( ) : integer
Результат integer

totalUniqueItems() публичный метод

Get the total number of unique items in the cart.
public totalUniqueItems ( ) : integer
Результат integer

update() публичный метод

Update an item in the cart.
public update ( string $itemId, string $key, mixed $value ) : string
$itemId string
$key string
$value mixed
Результат string