class Cart

Constants

DEFAULT_INSTANCE

Properties

protected Store $session

Instance of the session manager.

protected Dispatcher $events

Instance of the event dispatcher.

protected string $instance

Holds the current cart instance.

protected CartConditions $conditions

Instance of the cart condition.

Methods

__construct(SessionManager $session, Dispatcher $events)

Cart constructor.

instance(string|null $instance = null)

Set the current cart instance.

string
currentInstance()

Get the current cart instance.

array|CartItem
add($buyable, int $qty = 0, array $options = [], null $comment = null)

Add an item to the cart.

CartItem|bool
update(string $rowId, mixed $qty)

Update the cart item with the given rowId.

void
remove(string $rowId)

Remove the cart item with the given rowId from the cart.

get(string $rowId)

Get a cart item from the cart by its rowId.

void
destroy(mixed $identifier = null)

Destroy the current cart instance.

content()

Get the content of the cart.

int|float
count()

Get the number of items in the cart.

string
total()

Get the total price of the items (with conditions) in the cart.

float
subtotal()

Get the subtotal (with conditions) of the items in the cart.

search(Closure $search)

Search the cart content for a cart item matching the given search closure.

void
associate(string $rowId, mixed $model)

Associate the cart item with the given rowId with the given model.

conditions()

No description

getCondition($name)

Get condition applied on the cart by its name

bool
removeCondition($name)

Clear a condition on a cart by its name,

clearConditions()

No description

condition($condition)

No description

loadConditions()

No description

loadCondition(CartCondition $condition)

No description

applyAllConditionsToItem(CartItem $cartItem)

Applies all conditions to a cart item.

applyConditionToItem(CartCondition $condition, CartItem $cartItem)

No description

getApplicableItemCondition($condition, $cartItem)

No description

loadItemsCondition(CartCondition $condition)

Load condition on all existing cart items

removeItemCondition(CartCondition $condition)

Remove an applied condition from all cart items

clearItemConditions()

Remove all applied conditions from all cart items

clearContent()

No description

getContent()

Get the carts content, if there is no cart content set yet, return a new empty Collection

getConditions()

Get the carts conditions, if there is no cart condition set yet, return a new empty Collection

createCartItem($buyable, int $qty = 0, array $options = [], null $comment = null)

Create a new CartItem from the supplied attributes.

bool
isMulti(mixed $item)

Check if the item is a multidimensional array or an array of Buyables.

void
store(mixed $identifier)

Store the current instance of the cart.

restore(mixed $identifier)

Restore the cart with the given identifier.

deleteStored($identifier)

No description

bool
storedCartWithIdentifierExists($identifier)

No description

getStoredCartByIdentifier($identifier)

No description

mixed
createModel()

Create a new instance of the model

getSession($key, $default = null)

No description

putSession($key, $content)

No description

mixed
fireEvent($name, $payload = null)

No description

Details

at line 52
__construct(SessionManager $session, Dispatcher $events)

Cart constructor.

Parameters

SessionManager $session
Dispatcher $events

at line 67
Cart instance(string|null $instance = null)

Set the current cart instance.

Parameters

string|null $instance

Return Value

Cart

at line 83
string currentInstance()

Get the current cart instance.

Return Value

string

at line 98
array|CartItem add($buyable, int $qty = 0, array $options = [], null $comment = null)

Add an item to the cart.

Parameters

$buyable
int $qty
array $options
null $comment

Return Value

array|CartItem

at line 135
CartItem|bool update(string $rowId, mixed $qty)

Update the cart item with the given rowId.

Parameters

string $rowId
mixed $qty

Return Value

CartItem|bool

at line 186
void remove(string $rowId)

Remove the cart item with the given rowId from the cart.

Parameters

string $rowId

Return Value

void

at line 208
CartItem get(string $rowId)

Get a cart item from the cart by its rowId.

Parameters

string $rowId

Return Value

CartItem

at line 224
void destroy(mixed $identifier = null)

Destroy the current cart instance.

Parameters

mixed $identifier

Return Value

void

at line 240
CartContent content()

Get the content of the cart.

Return Value

CartContent

at line 250
int|float count()

Get the number of items in the cart.

Return Value

int|float

at line 260
string total()

Get the total price of the items (with conditions) in the cart.

Return Value

string

at line 270
float subtotal()

Get the subtotal (with conditions) of the items in the cart.

Return Value

float

Search the cart content for a cart item matching the given search closure.

Parameters

Closure $search

Return Value

CartContent

at line 297
void associate(string $rowId, mixed $model)

Associate the cart item with the given rowId with the given model.

Parameters

string $rowId
mixed $model

Return Value

void

at line 321
CartConditions conditions()

No description

Return Value

CartConditions

at line 337
CartCondition getCondition($name)

Get condition applied on the cart by its name

Parameters

$name

Return Value

CartCondition

at line 349
bool removeCondition($name)

Clear a condition on a cart by its name,

Parameters

$name

Return Value

bool

at line 365
clearConditions()

No description

at line 381
condition($condition)

No description

Parameters

$condition \Igniter\Flame\Cart\CartCondition

at line 387
loadConditions()

No description

at line 392
loadCondition(CartCondition $condition)

No description

Parameters

CartCondition $condition

at line 420
protected applyAllConditionsToItem(CartItem $cartItem)

Applies all conditions to a cart item.

Parameters

CartItem $cartItem

at line 427
protected applyConditionToItem(CartCondition $condition, CartItem $cartItem)

No description

Parameters

CartCondition $condition
CartItem $cartItem

at line 444
protected null|CartCondition getApplicableItemCondition($condition, $cartItem)

No description

Parameters

$condition
$cartItem

Return Value

null|CartCondition

at line 460
protected loadItemsCondition(CartCondition $condition)

Load condition on all existing cart items

Parameters

CartCondition $condition

at line 476
protected removeItemCondition(CartCondition $condition)

Remove an applied condition from all cart items

Parameters

CartCondition $condition

at line 490
protected clearItemConditions()

Remove all applied conditions from all cart items

at line 505
clearContent()

No description

at line 519
protected CartContent getContent()

Get the carts content, if there is no cart content set yet, return a new empty Collection

Return Value

CartContent

at line 532
protected CartConditions getConditions()

Get the carts conditions, if there is no cart condition set yet, return a new empty Collection

Return Value

CartConditions

at line 550
protected CartItem createCartItem($buyable, int $qty = 0, array $options = [], null $comment = null)

Create a new CartItem from the supplied attributes.

Parameters

$buyable
int $qty
array $options
null $comment

Return Value

CartItem

at line 572
protected bool isMulti(mixed $item)

Check if the item is a multidimensional array or an array of Buyables.

Parameters

mixed $item

Return Value

bool

at line 586
void store(mixed $identifier)

Store the current instance of the cart.

Parameters

mixed $identifier

Return Value

void

at line 607
restore(mixed $identifier)

Restore the cart with the given identifier.

Parameters

mixed $identifier

at line 636
deleteStored($identifier)

No description

Parameters

$identifier

at line 648
protected bool storedCartWithIdentifierExists($identifier)

No description

Parameters

$identifier

Return Value

bool

at line 655
protected getStoredCartByIdentifier($identifier)

No description

Parameters

$identifier

at line 666
protected mixed createModel()

Create a new instance of the model

Return Value

mixed

Exceptions

Exception

at line 679
protected getSession($key, $default = null)

No description

Parameters

$key
$default

at line 684
protected putSession($key, $content)

No description

Parameters

$key
$content

at line 699
protected mixed fireEvent($name, $payload = null)

No description

Parameters

$name
$payload

Return Value

mixed