Documentation

Cart extends BaseModel
in package
uses WithOwnerTrait, WithWebsiteTrait

Cart Model

Table of Contents

Properties

$table_name  : string|null
$billingAddress  : Address|null
$db_row  : Row
$discounts  : array<string|int, mixed>|null
$is_first_save  : bool
$items  : mixed
$keyField  : string|array<string|int, mixed>
$loadedObjects  : array<string|int, mixed>
$shippingAddress  : Address|null
$websiteModel  : Website|null
$original_data  : array<string|int, mixed>|null

Methods

__call()  : mixed
{@inheritdoc}
__construct()  : mixed
{@inheritdoc}
__get()  : mixed
{@inheritdoc}
__isset()  : bool
{@inheritdoc}
__set()  : void
{@inheritdoc}
__unset()  : void
{@inheritdoc}
addProduct()  : CartItem
Add a product to the cart
calculate()  : static
Calculate the cart totals
calculateShipping()  : float
Calculate shipping costs for the cart
checkLoaded()  : self
ensures model is loaded
current()  : mixed
{@inheritdoc}
defaultTableName()  : string
gets model table name
delete()  : self
removes model from db
fill()  : self
fills empty model with data
fullLoad()  : static
Full load of the cart, including items and discounts
getAdminCurrencyCode()  : string
getAdminDiscountAmount()  : float
getAdminShippingAmount()  : float
getAdminSubTotal()  : float
getAdminTaxAmount()  : float
getAdminTotalInclTax()  : float
getBillingAddress()  : Address|null
Get the billing address
getBillingAddressId()  : int
getCartItem()  : CartItem|null
Get a cart item by its ID
getChangedData()  : array<string|int, mixed>|null
gets model's changed data
getCollection()  : BaseCollection
returns a Model collection
getCreatedAt()  : DateTime
getCurrencyCode()  : string
getData()  : mixed
gets model's data
getDiscountAmount()  : float
getDiscounts()  : array<string|int, CartDiscount>|null
Get discounts associated with the cart
getId()  : int
getIsActive()  : bool
getItems()  : array<string|int, CartItem>
Get the name of the model
getIterator()  : Traversable|ArrayIterator
{@inheritdoc}
getKeyField()  : string|array<string|int, mixed>
getKeyFieldValue()  : mixed
getOwner()  : User
gets owner
getSearchCollection()  : BaseCollection
returns a Model collection using SearchManager for finding elements
getShippingAddress()  : Address|null
Get the shipping address
getShippingAddressId()  : int
getShippingAmount()  : float
getSubTotal()  : float
getTableColumns()  : mixed
getTaxAmount()  : float
getTotalInclTax()  : float
getUpdatedAt()  : DateTime
getUserId()  : int
getWebsite()  : Website
gets website
getWebsiteId()  : int
hydrateStatementResult()  : array<string|int, mixed>
returns an array of models, starting from a statement Result
isFirstSave()  : bool
is first save flag
isLoaded()  : bool
checks if model is loaded
isNew()  : bool
checks if model is new
key()  : mixed
{@inheritdoc}
load()  : self
loads model by id
loadBy()  : self
loads model by field - value pair
loadByCondition()  : self|null
loads model by condition
new()  : static
gets new empty model
next()  : mixed
{@inheritdoc}
offsetExists()  : bool
{@inheritdoc}
offsetGet()  : mixed
{@inheritdoc}
offsetSet()  : void
{@inheritdoc}
offsetUnset()  : void
{@inheritdoc}
persist()  : self
saves model on db
postLoad()  : self
post load hook
postPersist()  : self
post persist hook
postRemove()  : self
post remove hook
prePersist()  : self
pre persist hook
preRemove()  : self
pre remove hook
remove()  : self
removes model from db
removeItem()  : static
Remove an item from the cart
removeProduct()  : static
Remove a product from the cart
requireShipping()  : bool
Check if the cart requires shipping
reset()  : self
resets model
resetBillingAddress()  : static
Reset billing and shipping addresses
resetDiscounts()  : static
Reset discounts
resetItems()  : static
Reset items
resetShippingAddress()  : static
Reset shipping address
rewind()  : mixed
{@inheritdoc}
save()  : self
saves model on db
select()  : PDOStatement
basic select statement
setAdminCurrencyCode()  : self
setAdminDiscountAmount()  : self
setAdminShippingAmount()  : self
setAdminSubTotal()  : self
setAdminTaxAmount()  : self
setAdminTotalInclTax()  : self
setBillingAddress()  : static
Set the billing address
setBillingAddressId()  : self
setCreatedAt()  : self
setCurrencyCode()  : self
setData()  : self
sets model's data
setDiscountAmount()  : self
setId()  : self
setIsActive()  : self
setIsFirstSave()  : $this
sets is first save flag
setShippingAddress()  : static
Set the shipping address
setShippingAddressId()  : self
setShippingAmount()  : self
setSubTotal()  : self
setTableName()  : self
setTaxAmount()  : self
setTotalInclTax()  : self
setUpdatedAt()  : self
setUserId()  : self
setWebsiteId()  : self
toJson()  : string
gets Model json rapresentation
valid()  : mixed
{@inheritdoc}
emitEvent()  : mixed
getDbRow()  : Row
getModelBasicWhere()  : Result
gets basic where statement for model
getModelName()  : string
gets object model name
getOriginalData()  : mixed
gets model's original data
getTableName()  : string
gets table name
loadCartItems()  : static
Load cart items from the database if not already loaded
loadDiscounts()  : static
Load discounts associated with the cart
loadedObjectsIdentifier()  : string
setDbRow()  : self
setOriginalData()  : $this
sets model's original data
checkDbName()  : self
checks if Row object is from correct table

Properties

$table_name

public string|null $table_name = null

table name

$billingAddress

protected Address|null $billingAddress = null

$db_row

protected Row $db_row = null

database row

$discounts

protected array<string|int, mixed>|null $discounts = null

$is_first_save

protected bool $is_first_save

first save flag

$items

protected mixed $items = []

$keyField

protected static string|array<string|int, mixed> $keyField = 'id'

$loadedObjects

protected static array<string|int, mixed> $loadedObjects = []

objects cache

$shippingAddress

protected Address|null $shippingAddress = null

$original_data

private array<string|int, mixed>|null $original_data = null

original model data

Methods

__call()

{@inheritdoc}

public __call(string $name, mixed $arguments) : mixed
Parameters
$name : string
$arguments : mixed
Tags
throws
Exception

__construct()

{@inheritdoc}

public __construct([Row|null $db_row = null ]) : mixed
Parameters
$db_row : Row|null = null
Tags
throws
InvalidValueException
throws
BasicException

__get()

{@inheritdoc}

public __get(mixed $key) : mixed
Parameters
$key : mixed

__isset()

{@inheritdoc}

public __isset(mixed $name) : bool
Parameters
$name : mixed
Return values
bool

__set()

{@inheritdoc}

public __set(mixed $key, mixed $value) : void
Parameters
$key : mixed
$value : mixed

__unset()

{@inheritdoc}

public __unset(mixed $name) : void
Parameters
$name : mixed

calculate()

Calculate the cart totals

public calculate() : static
Return values
static

calculateShipping()

Calculate shipping costs for the cart

public calculateShipping() : float
Return values
float

checkLoaded()

ensures model is loaded

public checkLoaded() : self
Tags
throws
Exception
Return values
self

current()

{@inheritdoc}

public current() : mixed

defaultTableName()

gets model table name

public static defaultTableName() : string
Return values
string

delete()

removes model from db

public delete() : self
Tags
throws
BasicException
Return values
self

fill()

fills empty model with data

public fill(int|Row $id) : self
Parameters
$id : int|Row
Tags
throws
InvalidValueException
throws
BasicException
Return values
self

fullLoad()

Full load of the cart, including items and discounts

public fullLoad() : static
Return values
static

getAdminCurrencyCode()

public getAdminCurrencyCode() : string
Return values
string

getAdminDiscountAmount()

public getAdminDiscountAmount() : float
Return values
float

getAdminShippingAmount()

public getAdminShippingAmount() : float
Return values
float

getAdminSubTotal()

public getAdminSubTotal() : float
Return values
float

getAdminTaxAmount()

public getAdminTaxAmount() : float
Return values
float

getAdminTotalInclTax()

public getAdminTotalInclTax() : float
Return values
float

getBillingAddress()

Get the billing address

public getBillingAddress() : Address|null
Return values
Address|null

getBillingAddressId()

public getBillingAddressId() : int
Return values
int

getCartItem()

Get a cart item by its ID

public getCartItem(int $cartItemId) : CartItem|null
Parameters
$cartItemId : int
Return values
CartItem|null

getChangedData()

gets model's changed data

public getChangedData() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null

getCreatedAt()

public getCreatedAt() : DateTime
Return values
DateTime

getCurrencyCode()

public getCurrencyCode() : string
Return values
string

getData()

gets model's data

public getData([mixed|null $column = null ]) : mixed
Parameters
$column : mixed|null = null

getDiscountAmount()

public getDiscountAmount() : float
Return values
float

getDiscounts()

Get discounts associated with the cart

public getDiscounts() : array<string|int, CartDiscount>|null
Return values
array<string|int, CartDiscount>|null

getId()

public getId() : int
Return values
int

getIsActive()

public getIsActive() : bool
Return values
bool

getItems()

Get the name of the model

public getItems() : array<string|int, CartItem>
Return values
array<string|int, CartItem>

getIterator()

{@inheritdoc}

public getIterator() : Traversable|ArrayIterator
Return values
Traversable|ArrayIterator

getKeyField()

public static getKeyField() : string|array<string|int, mixed>
Return values
string|array<string|int, mixed>

getKeyFieldValue()

public getKeyFieldValue() : mixed

getSearchCollection()

returns a Model collection using SearchManager for finding elements

public static getSearchCollection([array<string|int, mixed> $conditions = [] ]) : BaseCollection
Parameters
$conditions : array<string|int, mixed> = []
Return values
BaseCollection

getShippingAddress()

Get the shipping address

public getShippingAddress() : Address|null
Return values
Address|null

getShippingAddressId()

public getShippingAddressId() : int
Return values
int

getShippingAmount()

public getShippingAmount() : float
Return values
float

getSubTotal()

public getSubTotal() : float
Return values
float

getTableColumns()

public static getTableColumns() : mixed

getTaxAmount()

public getTaxAmount() : float
Return values
float

getTotalInclTax()

public getTotalInclTax() : float
Return values
float

getUpdatedAt()

public getUpdatedAt() : DateTime
Return values
DateTime

getUserId()

public getUserId() : int
Return values
int

getWebsiteId()

public getWebsiteId() : int
Return values
int

hydrateStatementResult()

returns an array of models, starting from a statement Result

public static hydrateStatementResult(Result $stmt) : array<string|int, mixed>
Parameters
$stmt : Result
Tags
throws
DependencyException
throws
NotFoundException
Return values
array<string|int, mixed>

isFirstSave()

is first save flag

public isFirstSave() : bool
Return values
bool

isLoaded()

checks if model is loaded

public isLoaded() : bool
Return values
bool

isNew()

checks if model is new

public isNew() : bool
Return values
bool

load()

loads model by id

public static load(mixed $id[, bool $reset = false ]) : self
Parameters
$id : mixed
$reset : bool = false
Return values
self

loadBy()

loads model by field - value pair

public static loadBy(string $field, mixed $value) : self
Parameters
$field : string
$value : mixed
Tags
throws
BasicException
throws
DependencyException
throws
NotFoundException
Return values
self

loadByCondition()

loads model by condition

public static loadByCondition(array<string|int, mixed> $condition) : self|null
Parameters
$condition : array<string|int, mixed>
Tags
throws
BasicException
throws
DependencyException
throws
NotFoundException
Return values
self|null

new()

gets new empty model

public static new([array<string|int, mixed> $initial_data = [] ]) : static
Parameters
$initial_data : array<string|int, mixed> = []
Tags
throws
InvalidValueException
throws
BasicException
Return values
static

offsetExists()

{@inheritdoc}

public offsetExists(mixed $offset) : bool
Parameters
$offset : mixed
Return values
bool

offsetGet()

{@inheritdoc}

public offsetGet(mixed $offset) : mixed
Parameters
$offset : mixed

offsetSet()

{@inheritdoc}

public offsetSet(mixed $offset, mixed $value) : void
Parameters
$offset : mixed
$value : mixed

offsetUnset()

{@inheritdoc}

public offsetUnset(mixed $offset) : void
Parameters
$offset : mixed

persist()

saves model on db

public persist([bool $recursive = true ]) : self
Parameters
$recursive : bool = true
Tags
throws
BasicException
Return values
self

postLoad()

post load hook

public postLoad() : self
Return values
self

postPersist()

post persist hook

public postPersist() : self
Return values
self

postRemove()

post remove hook

public postRemove() : self
Return values
self

prePersist()

pre persist hook

public prePersist() : self
Return values
self

preRemove()

pre remove hook

public preRemove() : self
Return values
self

remove()

removes model from db

public remove() : self
Tags
throws
BasicException
Return values
self

removeItem()

Remove an item from the cart

public removeItem(CartItem|int $cartItem) : static
Parameters
$cartItem : CartItem|int
Return values
static

requireShipping()

Check if the cart requires shipping

public requireShipping() : bool
Return values
bool

reset()

resets model

public reset() : self
Tags
throws
BasicException
Return values
self

resetBillingAddress()

Reset billing and shipping addresses

public resetBillingAddress() : static
Return values
static

resetDiscounts()

Reset discounts

public resetDiscounts() : static
Return values
static

resetItems()

Reset items

public resetItems() : static
Return values
static

resetShippingAddress()

Reset shipping address

public resetShippingAddress() : static
Return values
static

rewind()

{@inheritdoc}

public rewind() : mixed

save()

saves model on db

public save() : self
Tags
throws
BasicException
Return values
self

select()

basic select statement

public static select([array<string|int, mixed> $options = [] ]) : PDOStatement
Parameters
$options : array<string|int, mixed> = []
Return values
PDOStatement

setAdminCurrencyCode()

public setAdminCurrencyCode(string $admin_currency_code) : self
Parameters
$admin_currency_code : string
Return values
self

setAdminDiscountAmount()

public setAdminDiscountAmount(float $admin_discount_amount) : self
Parameters
$admin_discount_amount : float
Return values
self

setAdminShippingAmount()

public setAdminShippingAmount(float $admin_shipping_amount) : self
Parameters
$admin_shipping_amount : float
Return values
self

setAdminSubTotal()

public setAdminSubTotal(float $admin_sub_total) : self
Parameters
$admin_sub_total : float
Return values
self

setAdminTaxAmount()

public setAdminTaxAmount(float $admin_tax_amount) : self
Parameters
$admin_tax_amount : float
Return values
self

setAdminTotalInclTax()

public setAdminTotalInclTax(float $admin_total_incl_tax) : self
Parameters
$admin_total_incl_tax : float
Return values
self

setBillingAddress()

Set the billing address

public setBillingAddress(Address $billingAddress) : static
Parameters
$billingAddress : Address
Return values
static

setBillingAddressId()

public setBillingAddressId(int $billing_address_id) : self
Parameters
$billing_address_id : int
Return values
self

setCreatedAt()

public setCreatedAt(DateTime $created_at) : self
Parameters
$created_at : DateTime
Return values
self

setCurrencyCode()

public setCurrencyCode(string $currency_code) : self
Parameters
$currency_code : string
Return values
self

setData()

sets model's data

public setData(array<string|int, mixed> $data) : self
Parameters
$data : array<string|int, mixed>
Return values
self

setDiscountAmount()

public setDiscountAmount(float $discount_amount) : self
Parameters
$discount_amount : float
Return values
self

setId()

public setId(int $id) : self
Parameters
$id : int
Return values
self

setIsActive()

public setIsActive(bool $is_active) : self
Parameters
$is_active : bool
Return values
self

setIsFirstSave()

sets is first save flag

public setIsFirstSave(bool $is_first_save) : $this
Parameters
$is_first_save : bool
Return values
$this

setShippingAddress()

Set the shipping address

public setShippingAddress(Address $shippingAddress) : static
Parameters
$shippingAddress : Address
Return values
static

setShippingAddressId()

public setShippingAddressId(int $shipping_address_id) : self
Parameters
$shipping_address_id : int
Return values
self

setShippingAmount()

public setShippingAmount(float $shipping_amount) : self
Parameters
$shipping_amount : float
Return values
self

setSubTotal()

public setSubTotal(float $sub_total) : self
Parameters
$sub_total : float
Return values
self

setTableName()

public setTableName(string $table_name) : self
Parameters
$table_name : string
Return values
self

setTaxAmount()

public setTaxAmount(float $tax_amount) : self
Parameters
$tax_amount : float
Return values
self

setTotalInclTax()

public setTotalInclTax(float $total_incl_tax) : self
Parameters
$total_incl_tax : float
Return values
self

setUpdatedAt()

public setUpdatedAt(DateTime $updated_at) : self
Parameters
$updated_at : DateTime
Return values
self

setUserId()

public setUserId(int $user_id) : self
Parameters
$user_id : int
Return values
self

setWebsiteId()

public setWebsiteId(int $website_id) : self
Parameters
$website_id : int
Return values
self

toJson()

gets Model json rapresentation

public toJson([int $level = 0 ]) : string
Parameters
$level : int = 0

internally used

Return values
string

valid()

{@inheritdoc}

public valid() : mixed

emitEvent()

protected emitEvent(mixed $eventName) : mixed
Parameters
$eventName : mixed

getDbRow()

protected getDbRow() : Row
Return values
Row

database row

getModelBasicWhere()

gets basic where statement for model

protected static getModelBasicWhere([array<string|int, mixed>|null $condition = [] ][, array<string|int, mixed> $order = [] ]) : Result
Parameters
$condition : array<string|int, mixed>|null = []
$order : array<string|int, mixed> = []
Return values
Result

getModelName()

gets object model name

protected getModelName() : string
Return values
string

getOriginalData()

gets model's original data

protected getOriginalData([mixed|null $key = null ]) : mixed
Parameters
$key : mixed|null = null

getTableName()

gets table name

protected getTableName() : string
Return values
string

loadCartItems()

Load cart items from the database if not already loaded

protected loadCartItems() : static
Return values
static

loadDiscounts()

Load discounts associated with the cart

protected loadDiscounts() : static
Return values
static

loadedObjectsIdentifier()

protected static loadedObjectsIdentifier(mixed $id) : string
Parameters
$id : mixed
Return values
string

setDbRow()

protected setDbRow(Row $db_row) : self
Parameters
$db_row : Row
Return values
self

setOriginalData()

sets model's original data

protected setOriginalData(array<string|int, mixed>|null $original_data) : $this
Parameters
$original_data : array<string|int, mixed>|null
Return values
$this

checkDbName()

checks if Row object is from correct table

private checkDbName(Row $db_row) : self
Parameters
$db_row : Row
Tags
throws
InvalidValueException
Return values
self

        
On this page

Search results