Methods summary
public
|
#
__construct( integer $cart_name, Minphp\Session\Session $session )
Initializes the session cart
Initializes the session cart
Parameters
- $cart_name
- The name of the cart to use in the session
- $session
- session object
|
public
|
#
setCallback( string $action, callable $callback )
Sets a callback to be invoked when the given $method is called.
Sets a callback to be invoked when the given $method is called.
Parameters
- $action
- The action to invoke the callback on (supported actions: addItem, updateItem, removeItem)
- $callback
- callback to execute
|
public
array
|
#
get( )
Returns the cart
Returns
array An array of cart info including 'items' and any thing else set for the cart
|
public
|
#
emptyCart( )
Empties the cart by removing all items from it
Empties the cart by removing all items from it
|
public
|
|
public
mixed
|
#
getItem( integer $index )
Returns an item in the cart at the given index
Returns an item in the cart at the given index
Parameters
- $index
- The index of the item to return
Returns
mixed The item or null otherwise
|
public
integer
|
#
addItem( mixed $item )
Adds an item to the cart
Parameters
- $item
- The item to add to the cart
Returns
integer The index the item was added to
|
public
|
#
updateItem( integer $index, mixed $item )
Update an item in the cart
Update an item in the cart
Parameters
- $index
- The index to update
- $item
- The item to update at the given index
|
public
|
#
removeItems( array $indexes )
Removes a set of items from the cart
Removes a set of items from the cart
Parameters
- $indexes
- A list of indexes matching the cart item indexes for items to remove
|
public
mixed
|
#
removeItem( integer $index )
Remove an item from the cart
Remove an item from the cart
Parameters
- $index
- The index of the item to remove from the cart
Returns
mixed The item removed or null otherwise
|
public
mixed
|
#
prequeueItem( mixed $item )
Allows an item to be modified before it is added to the cart
Allows an item to be modified before it is added to the cart
Parameters
- $item
- An item to add to the queue
Returns
mixed Update $item content based on any triggered events
|
public
integer
|
#
enqueue( mixed $item )
Adds an item to the queue
Adds an item to the queue
Parameters
- $item
- An item to add to the queue
Returns
integer The index of the queued item
|
public
mixed
|
#
dequeue( integer $index = 0 )
Removes and returns the first item from the queue
Removes and returns the first item from the queue
Parameters
- $index
- The index to dequeue
Returns
mixed An item from the queue, null if no items exist
|
public
mixed
|
#
checkQueue( integer $index = 0 )
Returns the first item from the queue without removing it
Returns the first item from the queue without removing it
Parameters
- $index
- The index to peek at
Returns
mixed An item from the queue, null if no items exist
|
public
boolean
|
#
isEmptyQueue( )
Returns whether or not the queue is empty
Returns whether or not the queue is empty
Returns
boolean true if the queue is empty, false otherwise
|
public
boolean
|
#
isEmptyCart( )
Returns whether or not the cart is empty
Returns whether or not the cart is empty
Returns
boolean true if the cart is empty, false otherwise
|
public
|
#
setData( string $field, mixed $value )
Sets a specified field into the cart with the given value
Sets a specified field into the cart with the given value
Parameters
- $field
- The field key to set to the session
- $value
- The value to save to the cart for the field
|
public
mixed
|
#
getData( string $field )
Returns a specified field from the cart
Returns a specified field from the cart
Parameters
- $field
- The field name to fetch
Returns
mixed The value stored in the cart at $field
|