class CartItem implements Arrayable, Jsonable

Properties

string $rowId

The rowID of the cart item.

int|string $id

The ID of the cart item.

int|float $qty

The quantity for this cart item.

string $name

The name of the cart item.

float $price

The price of the cart item.

string $comment

The comment of the cart item.

array $options

The options for this cart item.

array $conditions

The conditions for this cart item.

protected string|null $associatedModel

The FQN of the associated model.

Methods

__construct(int|string $id, string $name, float $price, array $options = [], null $comment = null, array $conditions = [])

CartItem constructor.

float
price()

Returns the formatted price

float
subtotal()

Returns the subtotal.

subtotalWithoutConditions()

No description

comment()

No description

hasOptions()

No description

hasOptionValue($valueIndex)

No description

hasConditions()

No description

clearConditions()

No description

getModel()

No description

setQuantity(int|float $qty)

Set the quantity for this cart item.

setComment($comment)

No description

void
updateFromBuyable(Buyable $item)

Update the cart item from a Buyable.

void
updateFromArray(array $attributes)

Update the cart item from an array.

associate(mixed $model)

Associate the cart item with the given model.

mixed
__get(string $attribute)

Get an attribute from the cart item or get the associated model.

static CartItem
fromBuyable(Buyable $item, array $options = [], null $comment = null, array $conditions = [])

Create a new instance from a Buyable.

static CartItem
fromArray(array $attributes)

Create a new instance from the given array.

string
generateRowId(string $id, array $options)

Generate a unique id for the cart item.

makeCartItemOptions($options)

No description

makeCartItemConditions($conditions)

No description

array
toArray()

Get the instance as an array.

string
toJson(int $options = 0)

Convert the object to its JSON representation.

Details

at line 84
__construct(int|string $id, string $name, float $price, array $options = [], null $comment = null, array $conditions = [])

CartItem constructor.

Parameters

int|string $id
string $name
float $price
array $options
null $comment
array $conditions

at line 110
float price()

Returns the formatted price

Return Value

float

at line 121
float subtotal()

Returns the subtotal.

Subtotal is price for whole CartItem with options

Return Value

float

at line 128
subtotalWithoutConditions()

No description

at line 137
comment()

No description

at line 142
hasOptions()

No description

at line 147
hasOptionValue($valueIndex)

No description

Parameters

$valueIndex

at line 154
hasConditions()

No description

at line 159
clearConditions()

No description

at line 166
getModel()

No description

at line 178
setQuantity(int|float $qty)

Set the quantity for this cart item.

Parameters

int|float $qty

at line 186
setComment($comment)

No description

Parameters

$comment

at line 198
void updateFromBuyable(Buyable $item)

Update the cart item from a Buyable.

Parameters

Buyable $item

Return Value

void

at line 212
void updateFromArray(array $attributes)

Update the cart item from an array.

Parameters

array $attributes

Return Value

void

at line 232
CartItem associate(mixed $model)

Associate the cart item with the given model.

Parameters

mixed $model

Return Value

CartItem

at line 246
mixed __get(string $attribute)

Get an attribute from the cart item or get the associated model.

Parameters

string $attribute

Return Value

mixed

at line 269
static CartItem fromBuyable(Buyable $item, array $options = [], null $comment = null, array $conditions = [])

Create a new instance from a Buyable.

Parameters

Buyable $item
array $options
null $comment
array $conditions

Return Value

CartItem

at line 288
static CartItem fromArray(array $attributes)

Create a new instance from the given array.

Parameters

array $attributes

Return Value

CartItem

at line 308
protected string generateRowId(string $id, array $options)

Generate a unique id for the cart item.

Parameters

string $id
array $options

Return Value

string

at line 315
protected makeCartItemOptions($options)

No description

Parameters

$options

at line 325
protected makeCartItemConditions($conditions)

No description

Parameters

$conditions

at line 338
array toArray()

Get the instance as an array.

Return Value

array

at line 360
string toJson(int $options = 0)

Convert the object to its JSON representation.

Parameters

int $options

Return Value

string