CartItem
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
CartItem constructor.
Returns the formatted price
Returns the subtotal.
No description
No description
No description
No description
No description
No description
No description
Set the quantity for this cart item.
No description
Update the cart item from an array.
Get an attribute from the cart item or get the associated model.
Create a new instance from a Buyable.
Generate a unique id for the cart item.
No description
No description
Get the instance as an array.
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.
at line 110
float
price()
Returns the formatted price
at line 121
float
subtotal()
Returns the subtotal.
Subtotal is price for whole CartItem with options
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
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.
at line 186
setComment($comment)
No description
at line 198
void
updateFromBuyable(Buyable $item)
Update the cart item from a Buyable.
at line 212
void
updateFromArray(array $attributes)
Update the cart item from an array.
at line 232
CartItem
associate(mixed $model)
Associate the cart item with the given model.
at line 246
mixed
__get(string $attribute)
Get an attribute from the cart item or get the associated model.
at line 269
static CartItem
fromBuyable(Buyable $item, array $options = [], null $comment = null, array $conditions = [])
Create a new instance from a Buyable.
at line 288
static CartItem
fromArray(array $attributes)
Create a new instance from the given array.
at line 308
protected string
generateRowId(string $id, array $options)
Generate a unique id for the cart item.
at line 315
protected
makeCartItemOptions($options)
No description
at line 325
protected
makeCartItemConditions($conditions)
No description
at line 338
array
toArray()
Get the instance as an array.
at line 360
string
toJson(int $options = 0)
Convert the object to its JSON representation.