Order
extends BaseModel
in package
uses
WithOwnerTrait, WithWebsiteTrait
Order Model
Table of Contents
Properties
- $table_name : string|null
- $billingAddress : OrderAddress|null
- $db_row : Row
- $is_first_save : bool
- $items : array<string|int, mixed>
- $keyField : string|array<string|int, mixed>
- $loadedObjects : array<string|int, mixed>
- $orderPayment : OrderPayment|null
- $orderStatus : OrderStatus|null
- $shippingAddress : OrderAddress|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}
- calcOrderNumber() : string
- Calculate the order number based on the website ID and order ID
- checkLoaded() : self
- ensures model is loaded
- createFromCart() : self
- Create an order from a cart
- current() : mixed
- {@inheritdoc}
- defaultTableName() : string
- gets model table name
- delete() : self
- removes model from db
- fill() : self
- fills empty model with data
- getAdditionalData() : string
- getAdminCurrencyCode() : string
- getAdminDiscountAmount() : float
- getAdminShippingAmount() : float
- getAdminSubTotal() : float
- getAdminTaxAmount() : float
- getAdminTotalInclTax() : float
- getBillingAddress() : OrderAddress|null
- Get the billing address for this order
- getCartId() : int
- getChangedData() : array<string|int, mixed>|null
- gets model's changed data
- getCollection() : BaseCollection
- returns a Model collection
- getComments() : BaseCollection|null
- Get the comments associated with this order
- getCreatedAt() : DateTime
- getCurrencyCode() : string
- getData() : mixed
- gets model's data
- getDiscountAmount() : float
- getId() : int
- getItems() : array<string|int, OrderItem>
- Get the order items
- getIterator() : Traversable|ArrayIterator
- {@inheritdoc}
- getKeyField() : string|array<string|int, mixed>
- getKeyFieldValue() : mixed
- getOrderNumber() : string
- getOrderPayment() : OrderPayment|null
- Get the order payment
- getOrderStatus() : OrderStatus|null
- Get the order status
- getOrderStatusId() : int
- getOwner() : User
- gets owner
- getSearchCollection() : BaseCollection
- returns a Model collection using SearchManager for finding elements
- getShippingAddress() : OrderAddress|null
- Get the shipping address for this order
- 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}
- pay() : self
- Pay the order using a payment method
- 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
- reset() : self
- resets model
- rewind() : mixed
- {@inheritdoc}
- save() : self
- saves model on db
- select() : PDOStatement
- basic select statement
- setAdditionalData() : self
- setAdminCurrencyCode() : self
- setAdminDiscountAmount() : self
- setAdminShippingAmount() : self
- setAdminSubTotal() : self
- setAdminTaxAmount() : self
- setAdminTotalInclTax() : self
- setBillingAddress() : self
- Set the billing and shipping addresses for this order
- setCartId() : self
- setCreatedAt() : self
- setCurrencyCode() : self
- setData() : self
- sets model's data
- setDiscountAmount() : self
- setId() : self
- setIsFirstSave() : $this
- sets is first save flag
- setItems() : self
- Set the order items
- setOrderNumber() : self
- setOrderPayment() : self
- Set the order payment
- setOrderStatus() : self
- Set the order status and update related properties
- setOrderStatusId() : self
- setShippingAddress() : self
- Set the shipping address for this order
- 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
- 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
OrderAddress|null
$billingAddress
= null
$db_row
protected
Row
$db_row
= null
database row
$is_first_save
protected
bool
$is_first_save
first save flag
$items
protected
array<string|int, mixed>
$items
= []
$keyField
protected
static string|array<string|int, mixed>
$keyField
= 'id'
$loadedObjects
protected
static array<string|int, mixed>
$loadedObjects
= []
objects cache
$orderPayment
protected
OrderPayment|null
$orderPayment
= null
$orderStatus
protected
OrderStatus|null
$orderStatus
= null
$shippingAddress
protected
OrderAddress|null
$shippingAddress
= null
$websiteModel
protected
Website|null
$websiteModel
= 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
__construct()
{@inheritdoc}
public
__construct([Row|null $db_row = null ]) : mixed
Parameters
- $db_row : Row|null = null
Tags
__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
calcOrderNumber()
Calculate the order number based on the website ID and order ID
public
static calcOrderNumber(Order $order) : string
Parameters
- $order : Order
Return values
stringcheckLoaded()
ensures model is loaded
public
checkLoaded() : self
Tags
Return values
selfcreateFromCart()
Create an order from a cart
public
static createFromCart(Cart $cart) : self
Parameters
- $cart : Cart
Return values
selfcurrent()
{@inheritdoc}
public
current() : mixed
defaultTableName()
gets model table name
public
static defaultTableName() : string
Return values
stringdelete()
removes model from db
public
delete() : self
Tags
Return values
selffill()
fills empty model with data
public
fill(int|Row $id) : self
Parameters
- $id : int|Row
Tags
Return values
selfgetAdditionalData()
public
getAdditionalData() : string
Return values
stringgetAdminCurrencyCode()
public
getAdminCurrencyCode() : string
Return values
stringgetAdminDiscountAmount()
public
getAdminDiscountAmount() : float
Return values
floatgetAdminShippingAmount()
public
getAdminShippingAmount() : float
Return values
floatgetAdminSubTotal()
public
getAdminSubTotal() : float
Return values
floatgetAdminTaxAmount()
public
getAdminTaxAmount() : float
Return values
floatgetAdminTotalInclTax()
public
getAdminTotalInclTax() : float
Return values
floatgetBillingAddress()
Get the billing address for this order
public
getBillingAddress() : OrderAddress|null
Return values
OrderAddress|nullgetCartId()
public
getCartId() : int
Return values
intgetChangedData()
gets model's changed data
public
getChangedData() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|nullgetCollection()
returns a Model collection
public
static getCollection() : BaseCollection
Return values
BaseCollectiongetComments()
Get the comments associated with this order
public
getComments() : BaseCollection|null
Return values
BaseCollection|nullgetCreatedAt()
public
getCreatedAt() : DateTime
Return values
DateTimegetCurrencyCode()
public
getCurrencyCode() : string
Return values
stringgetData()
gets model's data
public
getData([mixed|null $column = null ]) : mixed
Parameters
- $column : mixed|null = null
getDiscountAmount()
public
getDiscountAmount() : float
Return values
floatgetId()
public
getId() : int
Return values
intgetItems()
Get the order items
public
getItems() : array<string|int, OrderItem>
Return values
array<string|int, OrderItem>getIterator()
{@inheritdoc}
public
getIterator() : Traversable|ArrayIterator
Return values
Traversable|ArrayIteratorgetKeyField()
public
static getKeyField() : string|array<string|int, mixed>
Return values
string|array<string|int, mixed>getKeyFieldValue()
public
getKeyFieldValue() : mixed
getOrderNumber()
public
getOrderNumber() : string
Return values
stringgetOrderPayment()
Get the order payment
public
getOrderPayment() : OrderPayment|null
Return values
OrderPayment|nullgetOrderStatus()
Get the order status
public
getOrderStatus() : OrderStatus|null
Return values
OrderStatus|nullgetOrderStatusId()
public
getOrderStatusId() : int
Return values
intgetOwner()
gets owner
public
getOwner() : User
Tags
Attributes
Return values
UsergetSearchCollection()
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
BaseCollectiongetShippingAddress()
Get the shipping address for this order
public
getShippingAddress() : OrderAddress|null
Return values
OrderAddress|nullgetShippingAmount()
public
getShippingAmount() : float
Return values
floatgetSubTotal()
public
getSubTotal() : float
Return values
floatgetTableColumns()
public
static getTableColumns() : mixed
getTaxAmount()
public
getTaxAmount() : float
Return values
floatgetTotalInclTax()
public
getTotalInclTax() : float
Return values
floatgetUpdatedAt()
public
getUpdatedAt() : DateTime
Return values
DateTimegetUserId()
public
getUserId() : int
Return values
intgetWebsite()
gets website
public
getWebsite() : Website
Tags
Attributes
Return values
WebsitegetWebsiteId()
public
getWebsiteId() : int
Return values
inthydrateStatementResult()
returns an array of models, starting from a statement Result
public
static hydrateStatementResult(Result $stmt) : array<string|int, mixed>
Parameters
- $stmt : Result
Tags
Return values
array<string|int, mixed>isFirstSave()
is first save flag
public
isFirstSave() : bool
Return values
boolisLoaded()
checks if model is loaded
public
isLoaded() : bool
Return values
boolisNew()
checks if model is new
public
isNew() : bool
Return values
boolkey()
{@inheritdoc}
public
key() : mixed
load()
loads model by id
public
static load(mixed $id[, bool $reset = false ]) : self
Parameters
- $id : mixed
- $reset : bool = false
Return values
selfloadBy()
loads model by field - value pair
public
static loadBy(string $field, mixed $value) : self
Parameters
- $field : string
- $value : mixed
Tags
Return values
selfloadByCondition()
loads model by condition
public
static loadByCondition(array<string|int, mixed> $condition) : self|null
Parameters
- $condition : array<string|int, mixed>
Tags
Return values
self|nullnew()
gets new empty model
public
static new([array<string|int, mixed> $initial_data = [] ]) : static
Parameters
- $initial_data : array<string|int, mixed> = []
Tags
Return values
staticnext()
{@inheritdoc}
public
next() : mixed
offsetExists()
{@inheritdoc}
public
offsetExists(mixed $offset) : bool
Parameters
- $offset : mixed
Return values
booloffsetGet()
{@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
pay()
Pay the order using a payment method
public
pay(string $payment_method_name, string $transaction_id[, mixed $additional_data = null ]) : self
Parameters
- $payment_method_name : string
- $transaction_id : string
- $additional_data : mixed = null
Return values
selfpersist()
saves model on db
public
persist([bool $recursive = true ]) : self
Parameters
- $recursive : bool = true
Tags
Return values
selfpostLoad()
post load hook
public
postLoad() : self
Return values
selfpostPersist()
post persist hook
public
postPersist() : self
Return values
selfpostRemove()
post remove hook
public
postRemove() : self
Return values
selfprePersist()
pre persist hook
public
prePersist() : self
Return values
selfpreRemove()
pre remove hook
public
preRemove() : self
Return values
selfremove()
removes model from db
public
remove() : self
Tags
Return values
selfreset()
resets model
public
reset() : self
Tags
Return values
selfrewind()
{@inheritdoc}
public
rewind() : mixed
save()
saves model on db
public
save() : self
Tags
Return values
selfselect()
basic select statement
public
static select([array<string|int, mixed> $options = [] ]) : PDOStatement
Parameters
- $options : array<string|int, mixed> = []
Return values
PDOStatementsetAdditionalData()
public
setAdditionalData(string $additional_data) : self
Parameters
- $additional_data : string
Return values
selfsetAdminCurrencyCode()
public
setAdminCurrencyCode(string $admin_currency_code) : self
Parameters
- $admin_currency_code : string
Return values
selfsetAdminDiscountAmount()
public
setAdminDiscountAmount(float $admin_discount_amount) : self
Parameters
- $admin_discount_amount : float
Return values
selfsetAdminShippingAmount()
public
setAdminShippingAmount(float $admin_shipping_amount) : self
Parameters
- $admin_shipping_amount : float
Return values
selfsetAdminSubTotal()
public
setAdminSubTotal(float $admin_sub_total) : self
Parameters
- $admin_sub_total : float
Return values
selfsetAdminTaxAmount()
public
setAdminTaxAmount(float $admin_tax_amount) : self
Parameters
- $admin_tax_amount : float
Return values
selfsetAdminTotalInclTax()
public
setAdminTotalInclTax(float $admin_total_incl_tax) : self
Parameters
- $admin_total_incl_tax : float
Return values
selfsetBillingAddress()
Set the billing and shipping addresses for this order
public
setBillingAddress(OrderAddress|Address $address) : self
Parameters
- $address : OrderAddress|Address
Return values
selfsetCartId()
public
setCartId(int $cart_id) : self
Parameters
- $cart_id : int
Return values
selfsetCreatedAt()
public
setCreatedAt(DateTime $created_at) : self
Parameters
- $created_at : DateTime
Return values
selfsetCurrencyCode()
public
setCurrencyCode(string $currency_code) : self
Parameters
- $currency_code : string
Return values
selfsetData()
sets model's data
public
setData(array<string|int, mixed> $data) : self
Parameters
- $data : array<string|int, mixed>
Return values
selfsetDiscountAmount()
public
setDiscountAmount(float $discount_amount) : self
Parameters
- $discount_amount : float
Return values
selfsetId()
public
setId(int $id) : self
Parameters
- $id : int
Return values
selfsetIsFirstSave()
sets is first save flag
public
setIsFirstSave(bool $is_first_save) : $this
Parameters
- $is_first_save : bool
Return values
$thissetItems()
Set the order items
public
setItems(array<string|int, OrderItem> $items) : self
Parameters
- $items : array<string|int, OrderItem>
Return values
selfsetOrderNumber()
public
setOrderNumber(string $order_number) : self
Parameters
- $order_number : string
Return values
selfsetOrderPayment()
Set the order payment
public
setOrderPayment(OrderPayment $orderPayment) : self
Parameters
- $orderPayment : OrderPayment
Return values
selfsetOrderStatus()
Set the order status and update related properties
public
setOrderStatus(OrderStatus $orderStatus) : self
Parameters
- $orderStatus : OrderStatus
Return values
selfsetOrderStatusId()
public
setOrderStatusId(int $order_status_id) : self
Parameters
- $order_status_id : int
Return values
selfsetShippingAddress()
Set the shipping address for this order
public
setShippingAddress(OrderAddress|Address $address) : self
Parameters
- $address : OrderAddress|Address
Return values
selfsetShippingAmount()
public
setShippingAmount(float $shipping_amount) : self
Parameters
- $shipping_amount : float
Return values
selfsetSubTotal()
public
setSubTotal(float $sub_total) : self
Parameters
- $sub_total : float
Return values
selfsetTableName()
public
setTableName(string $table_name) : self
Parameters
- $table_name : string
Return values
selfsetTaxAmount()
public
setTaxAmount(float $tax_amount) : self
Parameters
- $tax_amount : float
Return values
selfsetTotalInclTax()
public
setTotalInclTax(float $total_incl_tax) : self
Parameters
- $total_incl_tax : float
Return values
selfsetUpdatedAt()
public
setUpdatedAt(DateTime $updated_at) : self
Parameters
- $updated_at : DateTime
Return values
selfsetUserId()
public
setUserId(int $user_id) : self
Parameters
- $user_id : int
Return values
selfsetWebsiteId()
public
setWebsiteId(int $website_id) : self
Parameters
- $website_id : int
Return values
selftoJson()
gets Model json rapresentation
public
toJson([int $level = 0 ]) : string
Parameters
- $level : int = 0
-
internally used
Return values
stringvalid()
{@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
ResultgetModelName()
gets object model name
protected
getModelName() : string
Return values
stringgetOriginalData()
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
stringloadedObjectsIdentifier()
protected
static loadedObjectsIdentifier(mixed $id) : string
Parameters
- $id : mixed
Return values
stringsetDbRow()
protected
setDbRow(Row $db_row) : self
Parameters
- $db_row : Row
Return values
selfsetOriginalData()
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
$thischeckDbName()
checks if Row object is from correct table
private
checkDbName(Row $db_row) : self
Parameters
- $db_row : Row