Order
- Type
- Class
- Namespace
- craft\commerce\elements
- Inherits
- craft\commerce\elements\Order » craft\base\Element » craft\base\Component » craft\base\Model » yii\base\Model » yii\base\Component » yii\base\BaseObject
- Implements
- ArrayAccess, IteratorAggregate, craft\base\ComponentInterface, craft\base\ElementInterface, craft\base\ModelInterface, craft\commerce\base\HasStoreInterface, yii\base\Arrayable, yii\base\Configurable, yii\base\StaticInstanceInterface
- Uses traits
- craft\base\ClonefixTrait, craft\base\ElementTrait, craft\commerce\base\StoreTrait, craft\commerce\elements\traits\OrderElementTrait, craft\commerce\elements\traits\OrderNoticesTrait, craft\commerce\elements\traits\OrderValidatorsTrait, yii\base\ArrayableTrait, yii\base\StaticInstanceTrait
- Since
- 2.0
Order or Cart model.
Public Properties
Property | Description |
---|---|
actionMenuItems | |
activeCart | boolean – Is the current order the same as the active cart |
activeValidators | yii\validators\Validator – The validators applicable to the current scenario. |
additionalButtons | string |
adjustmentSubtotal | float, integer – the total of adjustments made to order |
adjustmentSubtotalAsCurrency | string |
adjustments | craft\commerce\models\OrderAdjustment[] |
adjustmentsTotal | float |
adjustmentsTotalAsCurrency | string |
ancestors | craft\elements\db\ElementQueryInterface – The element’s ancestors |
archived | boolean – Whether the element is archived |
attributes | array – Attribute values (name => value). |
attributesFromRequest | array – The attribute values |
availableShippingMethodOptions | craft\commerce\models\ShippingMethodOption[] |
awaitingFieldValues | boolean – Whether the element is still awaiting its custom field values |
behaviors | yii\base\Behavior – List of behaviors attached to this component. |
billingAddress | craft\elements\Address, null |
billingAddressId | integer, null – Billing address ID |
billingSameAsShipping | boolean – Make this the shipping address the same as the billing address |
cacheTags | string[] |
cancelUrl | string, null – Cancel URL |
canonical | craft\base\ElementInterface, null – The canonical element, if one exists for the current site |
canonicalId | integer, null – The element’s canonical ID |
canonicalUid | string – The element’s canonical UID |
cardBodyHtml | string, null |
children | craft\elements\db\ElementQueryInterface – The element’s children |
chipLabelHtml | string |
couponCode | string, null – Coupon Code |
cpEditUrl | string, null – The element’s edit URL in the control panel |
cpRevisionsUrl | string, null |
crumbs | array |
currency | string, null – Currency |
currentRevision | self , null |
customer | craft\elements\User, null |
customerId | integer, null – The order customer ID |
customerLinkHtml | string |
dateAuthorized | DateTime, null – Date authorized |
dateCreated | DateTime, null – The date that the element was created |
dateDeleted | DateTime, null – The date that the element was trashed |
dateLastMerged | DateTime, null – The date that the canonical element was last merged into this one |
dateOrdered | DateTime, null – Date ordered |
datePaid | DateTime, null – Date paid |
dateUpdated | DateTime, null – The date that the element was last updated |
deletedWithOwner | boolean, null – Whether the element was deleted along with its owner |
descendants | craft\elements\db\ElementQueryInterface – The element’s descendants |
dirtyAttributes | string[] |
dirtyFields | string[] |
draftId | integer, null – The ID of the draft’s row in the drafts table |
duplicateOf | craft\base\ElementInterface, null – The element that this element is being duplicated by. |
eagerLoadInfo | craft\elements\db\EagerLoadInfo, null – Info about the eager loading setup used to query this element. |
editorHtml | string – The HTML for the element’s editor HUD |
elementQueryResult | craft\base\ElementInterface, null – All elements that the element was queried with. |
string – the email for this order | |
enabled | boolean – Whether the element is enabled |
enabledForSite | boolean – Whether the element is enabled for this site |
errors | array – Errors for all attributes or the specified attribute. |
estimatedBillingAddress | null, array, craft\elements\Address |
estimatedBillingAddressId | integer, null – Estimated Billing address ID |
estimatedBillingSameAsShipping | boolean – Whether estimated billing address should be set to the same address as estimated shipping |
estimatedShippingAddress | null, array, craft\elements\Address |
estimatedShippingAddressId | integer, null – Estimated Shipping address ID |
fieldContext | string – The field context this element’s content uses |
fieldLayout | craft\models\FieldLayout, null – The field layout used by this element |
fieldLayoutId | integer, null – The element’s field layout ID |
fieldParamNamespace | array – The namespace used by custom field params on the request |
fieldValues | array – The element’s normalized custom field values, indexed by their handles |
firstErrors | array – The first errors. |
firstNotice | |
firstSave | boolean – Whether the element is being saved for the first time in a normal state (not as a draft or revision). |
forceSave | boolean – Whether the element should definitely be saved, if it’s a nested element being considered for saving by \craft\base\NestedElementManager . |
gateway | craft\commerce\base\Gateway |
gatewayId | integer, null – Gateway ID |
gqlTypeName | string |
hardDelete | boolean – Whether the element is being hard-deleted. |
hasDescendants | boolean – Whether the element has descendants |
histories | craft\commerce\models\OrderHistory[] – order histories |
htmlAttributes | array – Any attributes that should be included in the element’s DOM representation in the control panel |
id | integer, null – The element’s ID |
invalidNestedElementIds | integer[] |
isActiveCart | boolean – the order has the same ID as the current sessions cart |
isCanonical | boolean – Whether this is the canonical element |
isCompleted | boolean – Is completed |
isDerivative | boolean – Whether this is a derivative element, such as a draft or revision |
isDraft | boolean |
isEmpty | boolean – the order has no line items with any qty |
isFresh | boolean |
isHomepage | boolean |
isNewForSite | boolean – Whether the element is being saved to the current site for the first time. |
isPaid | boolean – if the order is paid |
isProvisionalDraft | boolean – Whether this is a provisional draft. |
isRevision | boolean |
isSlugTranslatable | boolean |
isTitleTranslatable | boolean |
isUnpaid | boolean – if the order is not paid |
isUnpublishedDraft | boolean |
itemSubtotal | integer – the total of all line item subtotals |
itemSubtotalAsCurrency | string |
itemTotal | float |
itemTotalAsCurrency | string |
iterator | ArrayIterator – An iterator for traversing the items in the list. |
language | string |
lastIp | string, null – Last IP address |
lastTransaction | null, craft\commerce\models\Transaction – The last transaction on the order. |
lazyEagerLoadedElements | string – The handle that was used to eager-load the elements |
level | integer, null – The element’s level within its structure |
lft | integer, null – The element’s left position within its structure |
lineItems | craft\commerce\models\LineItem[] |
link | \Twig\Markup , null – An anchor pre-filled with this element’s URL and title |
loadCartUrl | null, string |
localized | craft\elements\db\ElementQueryInterface, craft\elements\ElementCollection |
makePrimaryBillingAddress | boolean – Make this the customer‘s primary billing address |
makePrimaryShippingAddress | boolean – Make this the customer‘s primary shipping address |
mergingCanonicalChanges | boolean – Whether recent changes to the canonical element are being merged into this element. |
message | string, null – Message |
metadata | array |
modifiedAttributes | string[] |
modifiedFields | string[] |
nestedTransactions | craft\commerce\models\Transaction[] – transactions for the order that have child transactions set on them |
newSiteIds | integer[] – The site IDs that the element was just propagated to for the first time. |
next | craft\base\ElementInterface, null – The next element relative to this one, from a given set of criteria |
nextSibling | craft\base\ElementInterface, null – The element’s next sibling |
notices | craft\commerce\models\OrderNotice[] – Notices for all types or the specified type / attribute. |
number | string, null – Number |
orderAdjustments | craft\commerce\models\OrderAdjustment[] |
orderCompletedEmail | string, null – The email address when the order was completed |
orderLanguage | string, null – The language the order was made in. |
orderSite | craft\models\Site, null |
orderSiteId | integer, null – Order site ID |
orderStatus | craft\commerce\models\OrderStatus |
orderStatusHtml | string |
orderStatusId | integer, null – Order status ID |
origin | string, null – Order origin |
outdatedAttributes | string[] |
outdatedFields | string[] |
outstandingBalance | float – The balance amount to be paid on the Order |
outstandingBalanceAsCurrency | string |
paidStatus | string – the order’s paid status |
paidStatusHtml | string – the order’s paid status as HTML |
parent | craft\base\ElementInterface, null – The element’s parent |
parentId | integer, null – The element’s parent’s ID |
parentUri | string, null |
paymentAmount | float |
paymentCurrency | string – the payment currency for this order |
paymentSource | craft\commerce\models\PaymentSource, null |
paymentSourceId | integer, null – Payment source ID |
pdfUrl | string – the URL to the order’s PDF invoice |
postEditUrl | string, null |
prev | craft\base\ElementInterface, null – The previous element relative to this one, from a given set of criteria |
prevSibling | craft\base\ElementInterface, null – The element’s previous sibling |
previewTargets | array |
previewing | boolean – Whether the element is currently being previewed. |
propagateAll | boolean – Whether all element attributes should be propagated across all its supported sites, even if that means overwriting existing site-specific values. |
propagating | boolean – Whether the element is being saved in the context of propagating another site's version of the element. |
propagatingFrom | craft\base\ElementInterface, null – The element that this element is being propagated from. |
recalculationMode | string – the mode of recalculation. |
ref | string, null – The reference string to this element |
reference | string, null – Reference |
registerUserOnOrderComplete | boolean – Register user on order complete |
resaving | boolean – Whether the element is being resaved by a ResaveElement job or a resave console command. |
returnUrl | string, null – Return URL |
revisionId | integer, null – The ID of the revision’s row in the revisions table |
rgt | integer, null – The element’s right position within its structure |
root | integer, null – The element’s structure’s root ID |
route | mixed – The route that should be used when the element’s URI is requested |
saveBillingAddressOnOrderComplete | boolean – Save the order's billing address to the customer's address book |
saveShippingAddressOnOrderComplete | boolean – Save the order's shipping address to the customer's address book |
scenario | string – The scenario that this model is in. |
searchScore | integer, null – The element’s search score, if the craft\elements\db\ElementQuery::search() parameter was used when querying for the element |
serializedFieldValues | array – Array of the element’s serialized custom field values, indexed by their handles |
shippingAddress | craft\elements\Address, null |
shippingAddressId | integer, null – Shipping address ID |
shippingMethod | craft\commerce\base\ShippingMethodInterface |
shippingMethodHandle | string, null – Shipping Method Handle |
shippingMethodName | string, null – Shipping Method Name |
shippingSameAsBilling | boolean – Make this the shipping address the same as the billing address |
shortNumber | string |
siblings | craft\elements\db\ElementQueryInterface – All of the element’s siblings |
site | craft\models\Site – Site the element is associated with |
siteId | integer, null – The site ID the element is associated with |
siteSettingsId | integer, null – The ID of the element’s record in the elements_sites table |
slug | string, null – The element’s slug |
slugTranslationDescription | string, null |
slugTranslationKey | string – The translation key |
sourceBillingAddressId | integer, null – The billing address ID that was selected from the customer’s address book, which populated the billing address on the order. |
sourceId | integer, null |
sourceShippingAddressId | integer, null – The shipping address ID that was selected from the customer’s address book, which populated the shipping address on the order. |
sourceUid | string |
status | string, null – The element’s status |
store | craft\commerce\models\Store |
storeId | integer, null – Order store ID |
storedItemSubtotal | float, null – The item subtotal as stored in the database from last retrieval |
storedItemSubtotalAsCurrency | string |
storedItemTotal | float, null – The item total as stored in the database from last retrieval |
storedItemTotalAsCurrency | string |
storedTotal | float, null – The total as stored in the database from last retrieval |
storedTotalAsCurrency | string |
storedTotalDiscount | float, null – The total of discount adjustments as stored in the database from last retrieval |
storedTotalDiscountAsCurrency | string |
storedTotalPaid | float, null – The total paid as stored in the database from last retrieval |
storedTotalPaidAsCurrency | string |
storedTotalPrice | float, null – The total price as stored in the database from last retrieval |
storedTotalPriceAsCurrency | string |
storedTotalQty | integer, null – The total quantity as stored in the database from last retrieval |
storedTotalShippingCost | float, null – The total shipping cost adjustments as stored in the database from last retrieval |
storedTotalShippingCostAsCurrency | string |
storedTotalTax | float, null – The total tax adjustments as stored in the database from last retrieval |
storedTotalTaxAsCurrency | string |
storedTotalTaxIncluded | float, null – The total tax included adjustments as stored in the database from last retrieval |
storedTotalTaxIncludedAsCurrency | string |
structureId | integer, null – The element’s structure ID |
supportedSites | integer[], array – The sites this element is associated with |
suppressEmails | boolean |
tempId | string, null – The element’s temporary ID (only used if the element’s URI format contains {id}) |
title | string, null – The element’s title |
titleTranslationDescription | string, null |
titleTranslationKey | string – The translation key |
total | float |
totalAsCurrency | string |
totalAuthorized | float, integer |
totalCommittedStock | integer |
totalDescendants | integer – The total number of descendants that the element has |
totalDiscount | float |
totalDiscountAsCurrency | string |
totalPaid | float – the total purchase and captured transactions belonging to this order |
totalPaidAsCurrency | string |
totalPrice | float |
totalPriceAsCurrency | string |
totalPromotionalAmount | integer – the total sale amount |
totalQty | integer – the total number of items |
totalSaleAmount | |
totalSaleAmountAsCurrency | string |
totalShippingCost | float |
totalShippingCostAsCurrency | string |
totalTax | float |
totalTaxAsCurrency | string |
totalTaxIncluded | float |
totalTaxIncludedAsCurrency | string |
totalWeight | integer |
transactions | craft\commerce\models\Transaction[] |
trashed | boolean – Whether the element has been soft-deleted. |
uiLabel | |
uiLabelPath | string[] |
uid | string, null – The element’s UID |
updatingFromDerivative | boolean – Whether the element is being updated from a derivative element, such as a draft or revision. |
uri | string, null – The element’s URI |
uriFormat | string, null – The URI format used to generate this element’s URL |
url | string, null – The element’s full URL |
user | craft\elements\User, null |
validators | ArrayObject, yii\validators\Validator – All the validators declared in the model. |
activeCart
- Type
- boolean
- Default value
null
Is the current order the same as the active cart
adjustmentSubtotal
the total of adjustments made to order
adjustmentSubtotalAsCurrency
- Type
- string
- Default value
null
adjustments
- Type
- craft\commerce\models\OrderAdjustment[]
- Default value
null
adjustmentsTotal
- Type
- float
- Default value
null
adjustmentsTotalAsCurrency
- Type
- string
- Default value
null
availableShippingMethodOptions
- Type
- craft\commerce\models\ShippingMethodOption[]
- Default value
null
billingAddress
- Type
- craft\elements\Address, null
- Default value
null
billingAddressId
Billing address ID
Example
echo $order->billingAddressId;
{{ order.billingAddressId }}
billingSameAsShipping
- Type
- boolean
- Default value
false
Make this the shipping address the same as the billing address
Example
echo $order->billingSameAsShipping;
{{ order.billingSameAsShipping }}
cancelUrl
Cancel URL
Example
echo $order->cancelUrl;
{{ order.cancelUrl }}
couponCode
Coupon Code
Example
echo $order->couponCode;
{{ order.couponCode }}
currency
Currency
Example
echo $order->currency;
{{ order.currency }}
customer
- Type
- craft\elements\User, null
- Default value
null
customerId
The order customer ID
customerLinkHtml
- Type
- string
- Default value
null
dateAuthorized
Date authorized
Example
echo $order->dateAuthorized;
{{ order.dateAuthorized }}
dateOrdered
Date ordered
Example
echo $order->dateOrdered;
{{ order.dateOrdered }}
datePaid
Date paid
Example
echo $order->datePaid;
{{ order.datePaid }}
email
- Type
- string
- Default value
null
the email for this order
estimatedBillingAddress
- Type
- null, array, craft\elements\Address
- Default value
null
estimatedBillingAddressId
Estimated Billing address ID
estimatedBillingSameAsShipping
- Type
- boolean
- Default value
false
- Since
- 2.2
Whether estimated billing address should be set to the same address as estimated shipping
estimatedShippingAddress
- Type
- null, array, craft\elements\Address
- Default value
null
estimatedShippingAddressId
Estimated Shipping address ID
gateway
- Type
- craft\commerce\base\Gateway
- Default value
null
gatewayId
Gateway ID
Example
echo $order->gatewayId;
{{ order.gatewayId }}
histories
- Type
- craft\commerce\models\OrderHistory[]
- Default value
null
order histories
isActiveCart
- Type
- boolean
- Default value
null
the order has the same ID as the current sessions cart
isCompleted
- Type
- boolean
- Default value
false
Is completed
Example
echo $order->isCompleted;
{{ order.isCompleted }}
isEmpty
- Type
- boolean
- Default value
null
the order has no line items with any qty
isPaid
- Type
- boolean
- Default value
null
if the order is paid
isUnpaid
- Type
- boolean
- Default value
null
if the order is not paid
itemSubtotal
- Type
- integer
- Default value
null
the total of all line item subtotals
itemSubtotalAsCurrency
- Type
- string
- Default value
null
itemTotal
- Type
- float
- Default value
null
itemTotalAsCurrency
- Type
- string
- Default value
null
lastIp
Last IP address
Example
echo $order->lastIp;
{{ order.lastIp }}
lastTransaction
- Type
- null, craft\commerce\models\Transaction
- Default value
null
The last transaction on the order.
lineItems
- Type
- craft\commerce\models\LineItem[]
- Default value
null
loadCartUrl
makePrimaryBillingAddress
- Type
- boolean
- Default value
false
Make this the customer‘s primary billing address
Example
echo $order->makePrimaryBillingAddress;
{{ order.makePrimaryBillingAddress }}
makePrimaryShippingAddress
- Type
- boolean
- Default value
false
Make this the customer‘s primary shipping address
Example
echo $order->makePrimaryShippingAddress;
{{ order.makePrimaryShippingAddress }}
message
Message
Example
echo $order->message;
{{ order.message }}
metadata
- Type
- array
- Default value
null
nestedTransactions
- Type
- craft\commerce\models\Transaction[]
- Default value
null
transactions for the order that have child transactions set on them
number
Number
Example
echo $order->number;
{{ order.number }}
orderAdjustments
- Type
- craft\commerce\models\OrderAdjustment[]
- Default value
null
orderCompletedEmail
The email address when the order was completed
orderLanguage
The language the order was made in.
Example
echo $order->orderLanguage;
{{ order.orderLanguage }}
orderSite
- Type
- craft\models\Site, null
- Default value
null
orderSiteId
Order site ID
Example
echo $order->orderSiteId;
{{ order.orderSiteId }}
orderStatus
- Type
- craft\commerce\models\OrderStatus
- Default value
null
orderStatusHtml
- Type
- string
- Default value
null
orderStatusId
Order status ID
Example
echo $order->orderStatusId;
{{ order.orderStatusId }}
origin
Order origin
Example
echo $order->origin;
{{ order.origin }}
outstandingBalance
- Type
- float
- Default value
null
The balance amount to be paid on the Order
outstandingBalanceAsCurrency
- Type
- string
- Default value
null
paidStatus
- Type
- string
- Default value
null
the order’s paid status
paidStatusHtml
- Type
- string
- Default value
null
the order’s paid status as HTML
paymentAmount
- Type
- float
- Default value
null
paymentCurrency
- Type
- string
- Default value
null
the payment currency for this order
paymentSource
- Type
- craft\commerce\models\PaymentSource, null
- Default value
null
paymentSourceId
Payment source ID
Example
echo $order->paymentSourceId;
{{ order.paymentSourceId }}
pdfUrl
- Type
- string
- Default value
null
the URL to the order’s PDF invoice
recalculationMode
- Type
- string
- Default value
null
the mode of recalculation.
reference
Reference
Example
echo $order->reference;
{{ order.reference }}
registerUserOnOrderComplete
- Type
- boolean
- Default value
false
Register user on order complete
Example
echo $order->registerUserOnOrderComplete;
{{ order.registerUserOnOrderComplete }}
returnUrl
Return URL
Example
echo $order->returnUrl;
{{ order.returnUrl }}
saveBillingAddressOnOrderComplete
- Type
- boolean
- Default value
false
Save the order's billing address to the customer's address book
Example
echo $order->saveBillingAddressOnOrderComplete;
{{ order.saveBillingAddressOnOrderComplete }}
saveShippingAddressOnOrderComplete
- Type
- boolean
- Default value
false
Save the order's shipping address to the customer's address book
Example
echo $order->saveShippingAddressOnOrderComplete;
{{ order.saveShippingAddressOnOrderComplete }}
shippingAddress
- Type
- craft\elements\Address, null
- Default value
null
shippingAddressId
Shipping address ID
Example
echo $order->shippingAddressId;
{{ order.shippingAddressId }}
shippingMethod
- Type
- craft\commerce\base\ShippingMethodInterface
- Default value
null
shippingMethodHandle
Shipping Method Handle
shippingMethodName
Shipping Method Name
shippingSameAsBilling
- Type
- boolean
- Default value
false
Make this the shipping address the same as the billing address
Example
echo $order->shippingSameAsBilling;
{{ order.shippingSameAsBilling }}
shortNumber
- Type
- string
- Default value
null
sourceBillingAddressId
The billing address ID that was selected from the customer’s address book, which populated the billing address on the order.
sourceShippingAddressId
The shipping address ID that was selected from the customer’s address book, which populated the shipping address on the order.
storeId
Order store ID
Example
echo $order->storeId;
{{ order.storeId }}
storedItemSubtotal
The item subtotal as stored in the database from last retrieval
storedItemSubtotalAsCurrency
- Type
- string
- Default value
null
storedItemTotal
The item total as stored in the database from last retrieval
Example
echo $order->storedItemTotal;
{{ order.storedItemTotal }}
storedItemTotalAsCurrency
- Type
- string
- Default value
null
storedTotal
The total as stored in the database from last retrieval
Example
echo $order->storedTotal;
{{ order.storedTotal }}
storedTotalAsCurrency
- Type
- string
- Default value
null
storedTotalDiscount
The total of discount adjustments as stored in the database from last retrieval
Example
echo $order->storedTotalDiscount;
{{ order.storedTotalDiscount }}
storedTotalDiscountAsCurrency
- Type
- string
- Default value
null
storedTotalPaid
The total paid as stored in the database from last retrieval
Example
echo $order->storedTotalPaid;
{{ order.storedTotalPaid }}
storedTotalPaidAsCurrency
- Type
- string
- Default value
null
storedTotalPrice
The total price as stored in the database from last retrieval
Example
echo $order->storedTotalPrice;
{{ order.storedTotalPrice }}
storedTotalPriceAsCurrency
- Type
- string
- Default value
null
storedTotalQty
The total quantity as stored in the database from last retrieval
Example
echo $order->storedTotalQty;
{{ order.storedTotalQty }}
storedTotalShippingCost
The total shipping cost adjustments as stored in the database from last retrieval
Example
echo $order->storedTotalShippingCost;
{{ order.storedTotalShippingCost }}
storedTotalShippingCostAsCurrency
- Type
- string
- Default value
null
storedTotalTax
The total tax adjustments as stored in the database from last retrieval
Example
echo $order->storedTotalTax;
{{ order.storedTotalTax }}
storedTotalTaxAsCurrency
- Type
- string
- Default value
null
storedTotalTaxIncluded
The total tax included adjustments as stored in the database from last retrieval
Example
echo $order->storedTotalTaxIncluded;
{{ order.storedTotalTaxIncluded }}
storedTotalTaxIncludedAsCurrency
- Type
- string
- Default value
null
suppressEmails
- Type
- boolean
- Default value
false
total
- Type
- float
- Default value
null
totalAsCurrency
- Type
- string
- Default value
null
totalAuthorized
totalCommittedStock
- Type
- integer
- Default value
null
- Access
- Read-only
- Since
- 5.0.0
totalDiscount
- Type
- float
- Default value
null
totalDiscountAsCurrency
- Type
- string
- Default value
null
totalPaid
- Type
- float
- Default value
null
the total purchase
and captured
transactions belonging to this order
totalPaidAsCurrency
- Type
- string
- Default value
null
totalPrice
- Type
- float
- Default value
null
totalPriceAsCurrency
- Type
- string
- Default value
null
totalPromotionalAmount
- Type
- integer
- Default value
null
the total sale amount
totalQty
- Type
- integer
- Default value
null
the total number of items
totalSaleAmount
- Default value
null
- Access
- Read-only
totalSaleAmountAsCurrency
- Type
- string
- Default value
null
totalShippingCost
- Type
- float
- Default value
null
totalShippingCostAsCurrency
- Type
- string
- Default value
null
totalTax
- Type
- float
- Default value
null
totalTaxAsCurrency
- Type
- string
- Default value
null
totalTaxIncluded
- Type
- float
- Default value
null
totalTaxIncludedAsCurrency
- Type
- string
- Default value
null
totalWeight
- Type
- integer
- Default value
null
transactions
- Type
- craft\commerce\models\Transaction[]
- Default value
null
user
- Type
- craft\elements\User, null
- Default value
null
Protected Properties
Property | Description |
---|---|
revisionCreatorId | integer, null – Revision creator ID to be saved |
revisionNotes | string, null – Revision notes to be saved |
Public Methods
Method | Description |
---|---|
__call() | Calls the named method which is not a class method. |
__clone() | |
__construct() | |
__get() | Returns the value of a component property. |
__isset() | Checks if a property is set. |
__set() | Sets the value of a component property. |
__toString() | Returns the string representation of the element. |
__unset() | Sets a component property to be null. |
_getAdjustmentsTotalByType() | |
actions() | Returns the available bulk element actions for a given source. |
activeAttributes() | Returns the attribute names that are subject to validation in the current scenario. |
addError() | Adds a new error to the specified attribute. |
addErrors() | Adds a list of errors. |
addInvalidNestedElementIds() | Registers invalid nested element IDs with the element, so an error class can be added on their cards. |
addLineItem() | Adds a line item to the order. Updates the line item if the ID of that line item is already in the cart. |
addModelErrors() | Adds errors from another model, with a given attribute name prefix. |
addNotice() | Adds a new notice |
addNotices() | Adds a list of notices. |
afterDelete() | Performs actions after an element is deleted. |
afterDeleteForSite() | Performs actions after an element is deleted for a site. |
afterMoveInStructure() | Performs actions after an element is moved within a structure. |
afterOrderComplete() | Called after the order successfully completes |
afterPropagate() | Performs actions after an element is fully saved and propagated to other sites. |
afterRestore() | Performs actions after an element is restored. |
afterSave() | Performs actions after an element is saved. |
afterValidate() | This method is invoked after validation ends. |
attachBehavior() | Attaches a behavior to this component. |
attachBehaviors() | Attaches a list of behaviors to the component. |
attributeHints() | Returns the attribute hints. |
attributeLabels() | Returns the attribute labels. |
attributes() | Returns the list of attribute names. |
autoSetAddresses() | Automatically set addresses on the order if it's a cart and autoSetNewCartAddresses is true . |
autoSetPaymentSource() | |
autoSetShippingMethod() | Auto set shipping method based on config settings and available options |
beforeDelete() | Performs actions before an element is deleted. |
beforeDeleteForSite() | Performs actions before an element is deleted for a site. |
beforeMoveInStructure() | Performs actions before an element is moved within a structure. |
beforeRestore() | Performs actions before an element is restored. |
beforeSave() | Performs actions before an element is saved. |
beforeValidate() | This method is invoked before validation starts. |
behaviors() | |
canCreateDrafts() | Returns whether the given user is authorized to create drafts for this element. |
canDelete() | Returns whether the given user is authorized to delete this element. |
canDeleteForSite() | Returns whether the given user is authorized to delete this element for its current site. |
canDuplicate() | Returns whether the given user is authorized to duplicate this element. |
canDuplicateAsDraft() | Returns whether the given user is authorized to duplicate this element as an unpublished draft. |
canGetProperty() | Returns a value indicating whether a property can be read. |
canSave() | Returns whether the given user is authorized to save this element in its current form. |
canSetProperty() | Returns a value indicating whether a property can be set. |
canView() | Returns whether the given user is authorized to view this element’s edit page. |
className() | Returns the fully qualified name of this class. |
clearErrors() | Removes errors for all attributes or a single attribute. |
clearNotices() | Removes notices for all types or a single type. |
createAnother() | Creates a new element (without saving it) based on this one. |
createCondition() | Returns an element condition for the element type. |
createValidators() | Creates validator objects based on the validation rules specified in rules(). |
currencyAttributes() | The attributes on the order that should be made available as formatted currency. |
datetimeAttributes() | Returns the names of any attributes that should hold DateTime values. |
defaultTableAttributes() | Returns the list of table attribute keys that should be shown by default. |
detachBehavior() | Detaches a behavior from the component. |
detachBehaviors() | Detaches all behaviors from the component. |
displayName() | |
eagerLoadingMap() | Returns an array that maps source-to-target element IDs based on the given sub-property handle. |
ensureBehaviors() | Makes sure that the behaviors declared in behaviors() are attached to this component. |
exporters() | Returns the available export options for a given source. |
extraFields() | Returns the list of fields that can be expanded further and returned by toArray(). |
fieldLayouts() | Returns all the field layouts associated with elements from the given source. |
fields() | |
find() | Creates an craft\elements\db\ElementQueryInterface instance for query purpose. |
findAll() | Returns a list of elements that match the specified ID(s) or a set of element criteria parameters. |
findOne() | Returns a single element instance by a primary key or a set of element criteria parameters. |
findSource() | Returns a source definition by a given source key/path and context. |
formName() | Returns the form name that this model class should use. |
generateAttributeLabel() | Generates a user friendly attribute label based on the give attribute name. |
get() | |
getActionMenuItems() | |
getActiveValidators() | Returns the validators applicable to the current scenario. |
getAdditionalButtons() | Returns additional buttons that should be shown at the top of the element’s edit page. |
getAdjustmentSubtotal() | Returns the total of adjustments made to order. |
getAdjustments() | |
getAdjustmentsByType() | |
getAdjustmentsTotal() | |
getAncestors() | Returns the element’s ancestors. |
getAttributeHint() | Returns the text hint for the specified attribute. |
getAttributeHtml() | Returns the HTML that should be shown for a given attribute in table and card views. |
getAttributeLabel() | Returns the text label for the specified attribute. |
getAttributeStatus() | Returns the status of a given attribute. |
getAttributes() | Returns attribute values. |
getAvailableShippingMethodOptions() | |
getBehavior() | Returns the named behavior object. |
getBehaviors() | Returns all behaviors attached to this component. |
getBillingAddress() | Get the billing address on the order. |
getCacheTags() | Returns the cache tags that should be cleared when this element is saved. |
getCanonical() | Returns the canonical version of the element. |
getCanonicalId() | Returns the element’s canonical ID. |
getCanonicalUid() | Returns the element’s canonical UUID. |
getCardBodyHtml() | Returns the body HTML for element cards. |
getChildren() | Returns the element’s children. |
getChipLabelHtml() | Returns the label HTML for element chips. |
getCpEditUrl() | |
getCpRevisionsUrl() | Returns the element’s revisions index URL in the control panel. |
getCrumbs() | Returns the breadcrumbs that lead up to the element. |
getCurrentRevision() | Returns the element’s current revision, if one exists. |
getCustomer() | Returns the order's customer. |
getCustomerId() | Returns the order customer ID. |
getCustomerLinkHtml() | Customer represented as HTML Customer User link represented as HTML |
getDescendants() | Returns the element’s descendants. |
getDirtyAttributes() | Returns a list of attribute names that have changed since the element was first loaded. |
getDirtyFields() | Returns a list of custom field handles that have changed since the element was first loaded. |
getEagerLoadedElementCount() | Returns the count of eager-loaded elements for a given handle. |
getEagerLoadedElements() | Returns the eager-loaded elements for a given handle. |
getEmail() | Returns the email for this order. Will always be the customer's email if they exist. |
getEnabledForSite() | Returns whether the element is enabled for the current site. |
getErrorSummary() | Returns the errors for all attributes as a one-dimensional array. |
getErrors() | Returns the errors for all attributes or a single attribute. |
getEstimatedBillingAddress() | |
getEstimatedShippingAddress() | |
getFieldContext() | Returns the field context this element’s content uses. |
getFieldLayout() | Returns the field layout used by this element. |
getFieldParamNamespace() | Returns the namespace used by custom field params on the request. |
getFieldValue() | Returns the value for a given field. |
getFieldValues() | Returns the element’s normalized custom field values, indexed by their handles. |
getFirstError() | Returns the first error of the specified attribute. |
getFirstErrors() | Returns the first error of every attribute in the model. |
getFirstNotice() | Returns the first error of the specified type or attribute |
getGateway() | |
getGqlTypeName() | Returns the GraphQL type name for this element type. |
getHasDescendants() | Returns whether the element has descendants. |
getHistories() | |
getHtmlAttributes() | Returns any attributes that should be included in the element’s chips and cards. |
getId() | |
getInlineAttributeInputHtml() | Returns the HTML that should be shown for a given attribute's inline editing input. |
getInvalidNestedElementIds() | Returns the element’s invalid nested element IDs. |
getIsActiveCart() | Returns whether this order is the user's current active cart. |
getIsCanonical() | Returns whether this is the canonical element. |
getIsDerivative() | Returns whether this is a derivative element, such as a draft or revision. |
getIsDraft() | Returns whether this is a draft. |
getIsEmpty() | Returns whether the order has any items in it. |
getIsFresh() | Returns whether the element is "fresh" (not yet explicitly saved, and without validation errors). |
getIsHomepage() | Returns whether this element represents the site homepage. |
getIsPaid() | |
getIsRevision() | Returns whether this is a revision. |
getIsSlugTranslatable() | Returns whether the Slug field should be shown as translatable in the UI. |
getIsTitleTranslatable() | Returns whether the Title field should be shown as translatable in the UI. |
getIsUnpaid() | |
getIsUnpublishedDraft() | Returns whether the element is an unpublished draft. |
getItemSubtotal() | Returns the total of all line item's subtotals. |
getItemTotal() | |
getIterator() | Returns an iterator for traversing the attributes in the model. |
getLanguage() | Returns the language of the element. |
getLastTransaction() | |
getLineItems() | |
getLink() | Returns an anchor pre-filled with this element’s URL and title. |
getLoadCartUrl() | Returns the URL to the cart’s load action url |
getLocalized() | Returns the same element in other locales. |
getMetadata() | Returns element metadata that should be shown within the editor sidebar. |
getModifiedAttributes() | Returns the attribute names that have changed for this element. |
getModifiedFields() | Returns the field handles that have changed for this element. |
getNestedTransactions() | Returns an array of transactions for the order that have child transactions set on them. |
getNext() | Returns the next element relative to this one, from a given set of criteria. |
getNextSibling() | Returns the element’s next sibling. |
getNotices() | Returns the notices for all types/attributes or a single type/attributes. |
getOrderAdjustments() | |
getOrderSite() | Get the site for the order. |
getOrderStatus() | |
getOrderStatusHtml() | |
getOutdatedAttributes() | Returns the attribute names that have been updated on the canonical element since the last time it was merged into this element. |
getOutdatedFields() | Returns the field handles that have been updated on the canonical element since the last time it was merged into this element. |
getOutstandingBalance() | Returns the difference between the order amount and amount paid. |
getPaidStatus() | What is the status of the orders payment |
getPaidStatusHtml() | Paid status represented as HTML |
getParent() | Returns the element’s parent. |
getParentId() | Returns the parent ID. |
getParentUri() | Returns the parent element’s URI, if there is one. |
getPaymentAmount() | Returns the paymentAmount for this order. |
getPaymentCurrency() | Returns the current payment currency, and defaults to the primary currency if not set. |
getPaymentSource() | Returns the order's selected payment source if any. |
getPdfUrl() | Returns the URL to the order’s PDF invoice. |
getPostEditUrl() | Returns the URL that users should be redirected to after editing the element. |
getPrev() | Returns the previous element relative to this one, from a given set of criteria. |
getPrevSibling() | Returns the element’s previous sibling. |
getPreviewTargets() | Returns the additional locations that should be available for previewing the element, besides its primary URL. |
getRecalculationMode() | Gets the recalculation mode of the order |
getRef() | Returns the reference string to this element. |
getRoute() | Returns the route that should be used when the element’s URI is requested. |
getScenario() | Returns the scenario that this model is used in. |
getSearchKeywords() | Returns the search keywords for a given search attribute. |
getSerializedFieldValues() | Returns an array of the element’s serialized custom field values, indexed by their handles. |
getShippingAddress() | * Get the shipping address on the order. |
getShippingMethod() | |
getShortNumber() | |
getSiblings() | Returns all of the element’s siblings. |
getSidebarHtml() | Returns the HTML for any fields/info that should be shown within the editor sidebar. |
getSite() | Returns the site the element is associated with. |
getSlugTranslationDescription() | Returns the description of the Slug field’s translation support. |
getSlugTranslationKey() | Returns the Slug’s translation key. |
getSourceId() | Returns the element’s canonical ID. |
getSourceUid() | Returns the element’s canonical UID. |
getStatus() | |
getStore() | |
getSupportedSites() | Returns the sites this element is associated with. |
getThumbHtml() | |
getTitleTranslationDescription() | Returns the description of the Title field’s translation support. |
getTitleTranslationKey() | Returns the Title’s translation key. |
getTotal() | Returns the raw total of the order, which is the total of all line items and adjustments. This number can be negative, so it is not the price of the order. |
getTotalAuthorized() | |
getTotalCommittedStock() | |
getTotalDescendants() | Returns the total number of descendants that the element has. |
getTotalDiscount() | The total amount of discount adjustments. |
getTotalPaid() | Returns the total purchase and captured transactions belonging to this order. |
getTotalPrice() | Get the total price of the order, whose minimum value is enforced by the configured {@link Store::getMinimumTotalPriceStrategy() strategy set for minimum total price}. |
getTotalPromotionalAmount() | Returns the total promotional amount. |
getTotalQty() | Returns total number of items. |
getTotalSaleAmount() | Returns the total sale amount. |
getTotalShippingCost() | The total amount of shipping adjustments. |
getTotalTax() | The total amount of tax adjustments that are additive taxes that affect total price. |
getTotalTaxIncluded() | The total amount of tax adjustments on the order that are included in the price, and do not affect total price. |
getTotalWeight() | |
getTransactions() | |
getUiLabel() | |
getUiLabelPath() | Returns any path segment labels that should be prepended to the element’s UI label. |
getUriFormat() | Returns the URI format used to generate this element’s URI. |
getUrl() | Returns the element’s full URL. |
getUser() | |
getValidators() | Returns all the validators declared in rules(). |
gqlScopesByContext() | Returns the GraphQL scopes required by element’s context. |
hasDrafts() | Returns whether element indexes should show the “Drafts” status option. |
hasEagerLoadedElements() | Returns whether elements have been eager-loaded with a given handle. |
hasErrors() | Returns a value indicating whether there is any validation error. |
hasEventHandlers() | Returns a value indicating whether there is any handler attached to the named event. |
hasLineItems() | |
hasMatchingAddresses() | Returns whether the billing and shipping addresses' data matches |
hasMethod() | Returns a value indicating whether a method is defined. |
hasNotices() | Returns a value indicating whether there is any notices. |
hasOutstandingBalance() | |
hasProperty() | Returns a value indicating whether a property is defined for this component. |
hasRevisions() | Returns whether revisions should be created when this element is saved. |
hasShippableItems() | |
hasStatuses() | Returns whether elements of this type have statuses. |
hasThumbs() | Returns whether element indexes should include a thumbnail view by default. |
hasTitles() | Returns whether elements of this type have traditional titles. |
hasUris() | Returns whether elements of this type can have their own slugs and URIs. |
indexElementCount() | Returns the total number of elements that will be shown on an element index, for the given element query. |
indexHtml() | Returns the element index HTML. |
init() | Initializes the object. |
instance() | Returns static class instance, which can be used to obtain meta information. |
isAncestorOf() | Returns whether this element is an ancestor of another one. |
isAttributeActive() | Returns a value indicating whether the attribute is active in the current scenario. |
isAttributeDirty() | Returns whether an attribute has changed since the element was first loaded. |
isAttributeModified() | Returns whether an attribute value has changed for this element. |
isAttributeOutdated() | Returns whether an attribute value has fallen behind the canonical element’s value. |
isAttributeRequired() | Returns a value indicating whether the attribute is required. |
isAttributeSafe() | Returns a value indicating whether the attribute is safe for massive assignments. |
isChildOf() | Returns whether this element is a direct child of another one. |
isDescendantOf() | Returns whether this element is a descendant of another one. |
isFieldDirty() | Returns whether a custom field value has changed since the element was first loaded. |
isFieldEmpty() | Returns whether a field is empty. |
isFieldModified() | Returns whether a field value has changed for this element. |
isFieldOutdated() | Returns whether a field value has fallen behind the canonical element’s value. |
isLocalized() | Returns whether elements of this type store content on a per-site basis. |
isNextSiblingOf() | Returns whether this element is the direct next sibling of another one. |
isParentOf() | Returns whether this element is a direct parent of another one. |
isPaymentAmountPartial() | Returns whether the payment amount currently set is a partial amount of the order's outstanding balance. |
isPrevSiblingOf() | Returns whether this element is the direct previous sibling of another one. |
isSelectable() | Returns whether the component should be selectable in component Type selects. |
isSiblingOf() | Returns whether this element is a sibling of another one. |
lineItemsByPurchasable() | Returns any line item with that purchasable |
load() | Populates the model with input data. |
loadMultiple() | Populates a set of models with the data from end user. |
lowerDisplayName() | Returns the lowercase version of displayName(). |
markAsClean() | Resets the record of dirty attributes and fields. |
markAsComplete() | Marks the order as complete and sets the default order status, then saves the order. |
markAsDirty() | Marks all fields and attributes as dirty. |
mergeCanonicalChanges() | Merges changes from the canonical element into this one. |
modifyCustomSource() | Modifies a custom source’s config, before it’s returned by craft\services\ElementSources::getSources() |
off() | Detaches an existing event handler from this component. |
offsetExists() | Returns whether there is an element at the specified offset. |
offsetGet() | Returns the element at the specified offset. |
offsetSet() | Sets the element at the specified offset. |
offsetUnset() | Sets the element value at the specified offset to null. |
on() | Attaches an event handler to an event. |
onUnsafeAttribute() | This method is invoked when an unsafe attribute is being massively assigned. |
pluralDisplayName() | Returns the plural version of displayName(). |
pluralLowerDisplayName() | Returns the plural, lowercase version of displayName(). |
prepareEditScreen() | Prepares the response for the element’s Edit screen. |
recalculate() | Regenerates all adjusters and updates line items, depending on the current recalculationMode |
refHandle() | Returns the handle that should be used to refer to this element type from reference tags. |
removeBillingAddress() | |
removeLineItem() | Removes a specific line item from the order. |
removeShippingAddress() | |
render() | Renders the element using its partial template. |
rules() | Returns the validation rules for attributes. |
safeAttributes() | Returns the attribute names that are safe to be massively assigned in the current scenario. |
scenarios() | Returns a list of scenarios and the corresponding active attributes. |
searchableAttributes() | Defines which element attributes should be searchable. |
setAdjustments() | |
setAttributes() | Sets the attribute values in a massive way. |
setAttributesFromRequest() | Sets the element’s attributes from an element editor submission. |
setBillingAddress() | Set the billing address on the order. |
setCanonical() | Sets the canonical version of the element. |
setCanonicalId() | Sets the element’s canonical ID. |
setCustomer() | Sets the order's customer. |
setCustomerId() | Sets the order customer ID. |
setDirtyAttributes() | Sets the list of dirty attribute names. |
setDirtyFields() | Sets the list of dirty field handles. |
setEagerLoadedElementCount() | Sets the count of eager-loaded elements for a given handle. |
setEagerLoadedElements() | Sets some eager-loaded elements on a given handle. |
setEmail() | Sets the orders user based on the email address provided. |
setEnabledForSite() | Sets whether the element is enabled for the current site. |
setEstimatedBillingAddress() | |
setEstimatedShippingAddress() | |
setFieldParamNamespace() | Sets the namespace used by custom field params on the request. |
setFieldValue() | Sets the value for a given field. |
setFieldValueFromRequest() | Sets the value for a given field. The value should have originated from post data. |
setFieldValues() | Sets the element’s custom field values. |
setFieldValuesFromRequest() | Sets the element’s custom field values, when the values have come from post data. |
setGatewayId() | Sets the order's selected gateway id. |
setIsFresh() | Sets whether the element is "fresh" (not yet explicitly saved, and without validation errors). |
setLazyEagerLoadedElements() | Sets whether the given eager-loaded element handles were eager-loaded lazily. |
setLineItems() | |
setNext() | Sets the default next element. |
setParent() | Sets the element’s parent. |
setParentId() | Sets the parent ID. |
setPaymentAmount() | Sets the order's payment amount in the order's currency. This amount is not persisted. |
setPaymentCurrency() | |
setPaymentSource() | Sets the order's selected payment source |
setPrev() | Sets the default previous element. |
setRecalculationMode() | Sets the recalculation mode of the order |
setRevisionCreatorId() | Sets the revision creator ID to be saved. |
setRevisionNotes() | Sets the revision notes to be saved. |
setScenario() | Sets the scenario for the model. |
setShippingAddress() | Set the shipping address on the order. |
setTransactions() | Set transactions on the order. Set to null to clear cache and force next getTransactions() call to get the latest transactions. |
setUiLabel() | Defines what the element should be called within the control panel. |
setUiLabelPath() | Defines any path segment labels that should be prepended to the element’s UI label. |
sortOptions() | Returns the sort options for the element type. |
sourcePath() | Returns the source path for a given source key, step key, and context. |
sources() | Returns the source definitions that elements of this type may belong to. |
statuses() | |
tableAttributes() | Defines all of the available columns that can be shown in table views. |
toArray() | Converts the model into an array. |
trackChanges() | Returns whether Craft should keep track of attribute and custom field changes made to this element type, including when the last time they were changed, and who was logged-in at the time. |
trigger() | Triggers an event. |
updateOrderPaidInformation() | Updates the paid status and paid date of the order, and marks as complete if the order is paid or authorized. |
validate() | Performs the data validation. |
validateAddress() | Validates addresses, and also adds prefixed validation errors to order |
validateAddressCountry() | Validates that address country is in the allowed list. |
validateAddressReuse() | Validates that shipping address isn't being set to be the same as billing address, when billing address is set to be shipping address |
validateCouponCode() | |
validateCustomFieldAttribute() | Calls a custom validation function on a custom field. |
validateGatewayId() | |
validateLineItems() | Validates line items, and also adds prefixed validation errors to order |
validateMultiple() | Validates multiple models. |
validateOrganizationTaxIdAsVatId() | |
validatePaymentCurrency() | |
validatePaymentSourceId() |
__toString()
Returns the string representation of the element.
Returns
_getAdjustmentsTotalByType()
Arguments
$types
$included
addLineItem()
Adds a line item to the order. Updates the line item if the ID of that line item is already in the cart.
Arguments
$lineItem
afterOrderComplete()
Called after the order successfully completes
afterSave()
Performs actions after an element is saved.
Arguments
$isNew
(boolean) – Whether the element is brand new
attributes()
Returns the list of attribute names.
By default, this method returns all public non-static properties of the class. You may override this method to change the default behavior.
Returns
string[] – List of attribute names.
autoSetAddresses()
- Since
- 3.4.14
Automatically set addresses on the order if it's a cart and autoSetNewCartAddresses
is true
.
Returns
boolean – Returns true if order is mutated
Throws
autoSetPaymentSource()
- Since
- 4.2
Returns
Throws
autoSetShippingMethod()
- Since
- 4.1
Auto set shipping method based on config settings and available options
Returns
boolean – Returns true if order is mutated
beforeValidate()
This method is invoked before validation starts.
The default implementation raises a beforeValidate
event. You may override this method to do preliminary checks before validation. Make sure the parent implementation is invoked so that the event can be raised.
Returns
boolean – Whether the validation should be executed. Defaults to true. If false is returned, the validation will stop and the model is considered invalid.
behaviors()
canDelete()
Returns whether the given user is authorized to delete this element.
This will only be called if the element can be viewed and/or saved.
Arguments
$user
(craft\elements\User)
Returns
canDuplicate()
Returns whether the given user is authorized to duplicate this element.
This will only be called if the element can be viewed and/or saved.
Arguments
$user
(craft\elements\User)
Returns
canSave()
Returns whether the given user is authorized to save this element in its current form.
This will only be called if the element can be viewed.
Arguments
$user
(craft\elements\User)
Returns
canView()
Returns whether the given user is authorized to view this element’s edit page.
If they can view but not save, the edit form will either render statically, or be restricted to only saving changes as a draft, depending on canCreateDrafts().
Arguments
$user
(craft\elements\User)
Returns
currencyAttributes()
The attributes on the order that should be made available as formatted currency.
displayName()
Returns
extraFields()
Returns the list of fields that can be expanded further and returned by toArray().
This method is similar to fields() except that the list of fields returned by this method are not returned by default by toArray(). Only when field names to be expanded are explicitly specified when calling toArray(), will their values be exported.
The default implementation returns an empty array.
You may override this method to return a list of expandable fields based on some context information (e.g. the current application user).
Returns
array – The list of expandable field names or field definitions. Please refer to fields() on the format of the return value.
fields()
getAdjustmentSubtotal()
Returns the total of adjustments made to order.
Returns
Throws
getAdjustments()
Returns
craft\commerce\models\OrderAdjustment[], null
Throws
getAdjustmentsByType()
- Since
- 3.0
Arguments
$type
getAdjustmentsTotal()
getAvailableShippingMethodOptions()
- Since
- 3.1
Returns
craft\commerce\models\ShippingMethodOption[]
getBillingAddress()
Get the billing address on the order.
getCpEditUrl()
getCustomer()
Returns the order's customer.
Returns
Example
$customer = $order->customer;
<p>By {{ order.customer.name }}</p>
getCustomerId()
- Since
- 4.0.0
Returns the order customer ID.
Returns
getCustomerLinkHtml()
- Since
- 3.0
Customer represented as HTML Customer User link represented as HTML
Returns
getEmail()
Returns the email for this order. Will always be the customer's email if they exist.
Returns
getEstimatedBillingAddress()
- Since
- 2.2
getEstimatedShippingAddress()
- Since
- 2.2
getGateway()
Returns
craft\commerce\base\GatewayInterface, null
Throws
getHistories()
Returns
craft\commerce\models\OrderHistory[]
getIsActiveCart()
Returns whether this order is the user's current active cart.
Throws
getIsEmpty()
Returns whether the order has any items in it.
getIsPaid()
Returns
getIsUnpaid()
getItemSubtotal()
Returns the total of all line item's subtotals.
getItemTotal()
getLastTransaction()
getLineItems()
Returns
craft\commerce\models\LineItem[]
getLink()
Returns an anchor pre-filled with this element’s URL and title.
Arguments
$title
$options
Returns
\Twig\Markup
, null
getLoadCartUrl()
Returns the URL to the cart’s load action url
Returns
string, null – The URL to the order’s load cart URL, or null if the cart is an order
getMetadata()
Returns element metadata that should be shown within the editor sidebar.
Returns
array – The data, with keys representing the labels. The values can either be strings or callables. If a value is false
, it will be omitted.
getNestedTransactions()
Returns an array of transactions for the order that have child transactions set on them.
Returns
craft\commerce\models\Transaction[]
getOrderAdjustments()
getOrderSite()
- Since
- 3.2.9
Get the site for the order.
getOrderStatus()
Throws
getOrderStatusHtml()
Returns
Throws
getOutstandingBalance()
Returns the difference between the order amount and amount paid.
Returns
float – The outstanding balance.
getPaidStatus()
What is the status of the orders payment
getPaidStatusHtml()
Paid status represented as HTML
getPaymentAmount()
Returns the paymentAmount for this order.
Throws
getPaymentCurrency()
Returns the current payment currency, and defaults to the primary currency if not set.
getPaymentSource()
Returns the order's selected payment source if any.
Throws
- yii\base\InvalidConfigException
if the payment source is being set by a guest customer. - yii\base\InvalidArgumentException
if the order is set to an invalid payment source.
getPdfUrl()
Returns the URL to the order’s PDF invoice.
Arguments
$option
(string, null) – The option that should be available to the PDF template (e.g. “receipt”)$pdfHandle
(string, null) – The handle of the PDF to use. If none is passed the default PDF is used.
Returns
string, null – The URL to the order’s PDF invoice, or null if the PDF template doesn’t exist
getRecalculationMode()
Gets the recalculation mode of the order
getShippingAddress()
- Get the shipping address on the order.
getShippingMethod()
DEPRECATED
Deprecated in 3.4.18. Use $shippingMethodHandle
or $shippingMethodName
instead.
Returns
craft\commerce\models\ShippingMethod, null
Throws
getShortNumber()
getTotal()
Returns the raw total of the order, which is the total of all line items and adjustments. This number can be negative, so it is not the price of the order.
See also craft\commerce\elements\Order::getTotalPrice() – The actual total price of the order View source
getTotalAuthorized()
Returns
getTotalCommittedStock()
- Since
- 5.0.0
Returns
Throws
getTotalDiscount()
The total amount of discount adjustments.
Returns
getTotalPaid()
Returns the total purchase
and captured
transactions belonging to this order.
Returns
float – The total amount paid.
getTotalPrice()
Get the total price of the order, whose minimum value is enforced by the configured {@link Store::getMinimumTotalPriceStrategy() strategy set for minimum total price}.
getTotalPromotionalAmount()
- Since
- 5.0.0
Returns the total promotional amount.
getTotalQty()
Returns total number of items.
getTotalSaleAmount()
DEPRECATED
Deprecated in 5.0.0. Use getTotalPromotionalAmount() instead.
Returns the total sale amount.
getTotalShippingCost()
The total amount of shipping adjustments.
Returns
getTotalTax()
The total amount of tax adjustments that are additive taxes that affect total price.
Returns
getTotalTaxIncluded()
The total amount of tax adjustments on the order that are included in the price, and do not affect total price.
Returns
getTotalWeight()
getTransactions()
Returns
craft\commerce\models\Transaction[]
getUser()
DEPRECATED
Deprecated in 4.0.0. Use getCustomer() instead.
hasLineItems()
hasMatchingAddresses()
- Since
- 4.1.0
Returns whether the billing and shipping addresses' data matches
Arguments
Returns
hasOutstandingBalance()
Returns
boolean – Whether the order has an outstanding balance.
hasShippableItems()
- Since
- 3.4
init()
Initializes the object.
This method is invoked at the end of the constructor after the object is initialized with the given configuration.
isPaymentAmountPartial()
- Since
- 3.4.10
Returns whether the payment amount currently set is a partial amount of the order's outstanding balance.
Throws
lineItemsByPurchasable()
Returns any line item with that purchasable
Arguments
$purchasable
(craft\commerce\base\Purchasable)
Returns
\Illuminate\Support\Collection
lowerDisplayName()
Returns the lowercase version of displayName().
Returns
markAsComplete()
Marks the order as complete and sets the default order status, then saves the order.
Throws
- craft\commerce\errors\OrderStatusException
- yii\base\Exception
- Throwable
- craft\errors\ElementNotFoundException
pluralDisplayName()
Returns the plural version of displayName().
Returns
pluralLowerDisplayName()
Returns the plural, lowercase version of displayName().
Returns
recalculate()
Regenerates all adjusters and updates line items, depending on the current recalculationMode
Throws
removeBillingAddress()
- Since
- 3.1
removeLineItem()
Removes a specific line item from the order.
Arguments
$lineItem
removeShippingAddress()
- Since
- 3.1
setAdjustments()
Arguments
$adjustments
(craft\commerce\models\OrderAdjustment[])
setBillingAddress()
Set the billing address on the order.
Arguments
$address
(craft\elements\Address, array, null)
setCustomer()
Sets the order's customer.
Arguments
$customer
(craft\elements\User, null)
setCustomerId()
- Since
- 4.0.0
Sets the order customer ID.
Arguments
setEmail()
DEPRECATED
Deprecated in 4.3.0. Use setCustomer() instead.
Sets the orders user based on the email address provided.
Arguments
Throws
setEstimatedBillingAddress()
- Since
- 2.2
Arguments
$address
setEstimatedShippingAddress()
- Since
- 2.2
Arguments
$address
setGatewayId()
Sets the order's selected gateway id.
Arguments
$gatewayId
setLineItems()
Arguments
$lineItems
(craft\commerce\models\LineItem[])
setPaymentAmount()
Sets the order's payment amount in the order's currency. This amount is not persisted.
Arguments
$amount
Throws
setPaymentCurrency()
Arguments
$value
(string) – The payment currency code
setPaymentSource()
Sets the order's selected payment source
Arguments
$paymentSource
setRecalculationMode()
Sets the recalculation mode of the order
Arguments
$value
setShippingAddress()
Set the shipping address on the order.
Arguments
$address
(craft\elements\Address, array, null)
setTransactions()
- Since
- 3.2.0
Set transactions on the order. Set to null to clear cache and force next getTransactions() call to get the latest transactions.
Arguments
$transactions
(craft\commerce\models\Transaction[], null)
updateOrderPaidInformation()
Updates the paid status and paid date of the order, and marks as complete if the order is paid or authorized.
Protected Methods
Method | Description |
---|---|
attributeHtml() | Returns the HTML that should be shown for a given attribute in table and card views. |
cacheTags() | Returns the cache tags that should be cleared when this element is saved. |
cpEditUrl() | Returns the element’s edit URL in the control panel. |
cpRevisionsUrl() | Returns the element’s revisions index URL in the control panel. |
crumbs() | Returns the breadcrumbs that lead up to the element. |
defineActions() | Defines the available bulk element actions for a given source. |
defineBehaviors() | Returns the behaviors to attach to this class. |
defineDefaultTableAttributes() | Returns the list of table attribute keys that should be shown by default. |
defineExporters() | Defines the available element exporters for a given source. |
defineFieldLayouts() | Defines the field layouts associated with elements for a given source. |
defineRules() | Returns the validation rules for attributes. |
defineSearchableAttributes() | Defines which element attributes should be searchable. |
defineSortOptions() | Returns the sort options for the element type. |
defineSources() | Defines the sources that elements of this type may belong to. |
defineTableAttributes() | Defines all of the available columns that can be shown in table views. |
destructiveActionMenuItems() | Returns destructive action menu items for the element’s edit screens. |
extractFieldsFor() | Extract nested fields from a fields collection for a given root field Nested fields are separated with dots (.). e.g: "item.id" The previous example would extract "id". |
extractRootFields() | Extracts the root field names from nested fields. |
fieldByHandle() | Returns the field with a given handle. |
fieldLayoutFields() | Returns each of this element’s fields. |
findByCondition() | Finds Element instance(s) by the given condition. |
hasCheckeredThumb() | Returns whether the element’s thumbnail should have a checkered background. |
hasFieldLayout() | Returns whether the element has a field layout with at least one tab. |
hasNewParent() | Returns whether the element has been assigned a new parent. |
hasRoundedThumb() | Returns whether the element’s thumbnail should be rounded. |
htmlAttributes() | Returns any attributes that should be included in the element’s chips and cards. |
includeSetStatusAction() | Returns whether the Set Status action should be included in actions() automatically. |
indexElements() | Returns the resulting elements for an element index. |
inlineAttributeInputHtml() | Returns the HTML that should be shown for a given attribute’s inline input. |
metaFieldsHtml() | Returns the HTML for any meta fields that should be shown within the editor sidebar. |
metadata() | Returns element metadata that should be shown within the editor sidebar. |
normalizeFieldValue() | Normalizes a field’s value. |
notesFieldHtml() | Returns the notes field HTML for the sidebar. |
prepElementQueryForTableAttribute() | Prepares an element query for an element index that includes a given table attribute. |
previewTargets() | Returns the additional locations that should be available for previewing the element, besides its primary URL. |
resolveFields() | Determines which fields can be returned by toArray(). |
route() | Returns the route that should be used when the element’s URI is requested. |
safeActionMenuItems() | Returns action menu items for the element’s edit screens. |
searchKeywords() | Returns the search keywords for a given search attribute. |
shouldValidateTitle() | Returns whether the element’s title attribute should be validated |
showStatusField() | Returns whether the Status field should be shown for this element. |
slugFieldHtml() | Returns the HTML for the element’s Slug field. |
statusFieldHtml() | Returns the status field HTML for the sidebar. |
thumbAlt() | Returns alt text for the element’s thumbnail. |
thumbSvg() | Returns the element’s thumbnail SVG contents, which should be used as a fallback when \craft\base\getThumbUrl() returns null . |
thumbUrl() | Returns the URL to the element’s thumbnail, if it has one. |
uiLabel() | Returns what the element should be called within the control panel. |
defineRules()
Returns the validation rules for attributes.
See rules() for details about what should be returned.
Models should override this method instead of rules() so EVENT_DEFINE_RULES handlers can modify the class-defined rules.
Returns
Constants
Constant | Description |
---|---|
HOMEPAGE_URI | |
ORIGIN_CP | Order created from the control panel. |
ORIGIN_REMOTE | Order created by a remote source. |
ORIGIN_WEB | Order created from the front end. |
PAID_STATUS_OVERPAID | Payments exceed order total. |
PAID_STATUS_PAID | Payments equal order total. |
PAID_STATUS_PARTIAL | Payments less than order total. |
PAID_STATUS_UNPAID | Payments total zero on non-free order. |
RECALCULATION_MODE_ADJUSTMENTS_ONLY | Recalculates adjustments only; does not recalculate line items or populate from purchasables. |
RECALCULATION_MODE_ALL | Recalculates line items, populates from purchasables, and regenerates adjustments. |
RECALCULATION_MODE_NONE | Does not recalculate anything on the order. |
SCENARIO_DEFAULT | The name of the default scenario. |
SCENARIO_ESSENTIALS | |
SCENARIO_LIVE | |
STATUS_ARCHIVED | |
STATUS_DISABLED | |
STATUS_DRAFT | |
STATUS_ENABLED |
Events
EVENT_AFTER_ADD_LINE_ITEM
- Type
- yii\base\Event
The event that is triggered after a line item has been added to an order.
use craft\commerce\elements\Order;
use craft\commerce\events\LineItemEvent;
use craft\commerce\models\LineItem;
use yii\base\Event;
Event::on(
Order::class,
Order::EVENT_AFTER_ADD_LINE_ITEM,
function(LineItemEvent $event) {
// @var LineItem $lineItem
$lineItem = $event->lineItem;
// @var bool $isNew
$isNew = $event->isNew;
// ...
}
);
EVENT_AFTER_APPLY_ADD_LINE_ITEM
- Type
- yii\base\Event
The event that is triggered after a line item has been added to an order.
use craft\commerce\elements\Order;
use craft\commerce\events\LineItemEvent;
use craft\commerce\models\LineItem;
use yii\base\Event;
Event::on(
Order::class,
Order::EVENT_AFTER_APPLY_ADD_LINE_ITEM,
function(LineItemEvent $event) {
// @var LineItem $lineItem
$lineItem = $event->lineItem;
// @var bool $isNew
$isNew = $event->isNew;
// ...
}
);
EVENT_AFTER_APPLY_REMOVE_LINE_ITEM
- Type
- yii\base\Event
The event that is triggered after a line item has been removed from an order.
use craft\commerce\elements\Order;
use craft\commerce\events\LineItemEvent;
use craft\commerce\models\LineItem;
use yii\base\Event;
Event::on(
Order::class,
Order::EVENT_AFTER_APPLY_REMOVE_LINE_ITEM,
function(LineItemEvent $event) {
// @var LineItem $lineItem
$lineItem = $event->lineItem;
// @var bool $isNew
$isNew = $event->isNew;
// ...
}
);
EVENT_AFTER_COMPLETE_ORDER
- Type
- yii\base\Event
The event that is triggered after an order is completed.
use craft\commerce\elements\Order;
use yii\base\Event;
Event::on(
Order::class,
Order::EVENT_AFTER_COMPLETE_ORDER,
function(Event $event) {
// @var Order $order
$order = $event->sender;
// ...
}
);
EVENT_AFTER_LINE_ITEMS_REFRESHED
- Type
- yii\base\Event
- Since
- 5.1.0
The event that is triggered after line items are refreshed during recalculation of an order.
use craft\commerce\elements\Order;
use craft\commerce\events\OrderLineItemsRefreshEvent;
use yii\base\Event;
Event::on(
Order::class,
Order::EVENT_AFTER_LINE_ITEMS_REFRESHED,
function(OrderLineItemsRefreshEvent $event) {
$event->lineItems = [];
$event->recalculate = true;
// ...
}
);
EVENT_AFTER_ORDER_AUTHORIZED
- Type
- yii\base\Event
This event is raised after an order is authorized in full and completed
Plugins can get notified after an order is authorized in full and completed
use craft\commerce\elements\Order;
use yii\base\Event;
Event::on(Order::class, Order::EVENT_AFTER_ORDER_AUTHORIZED, function(Event $e) {
// @var Order $order
$order = $e->sender;
// ...
});
EVENT_AFTER_ORDER_PAID
- Type
- yii\base\Event
The event that is triggered after an order is paid and completed.
use craft\commerce\elements\Order;
use yii\base\Event;
Event::on(
Order::class,
Order::EVENT_AFTER_ORDER_PAID,
function(Event $event) {
// @var Order $order
$order = $event->sender;
// ...
}
);
EVENT_AFTER_REMOVE_LINE_ITEM
- Type
- yii\base\Event
The event that is triggered after a line item has been removed from an order.
use craft\commerce\elements\Order;
use craft\commerce\events\LineItemEvent;
use craft\commerce\models\LineItem;
use yii\base\Event;
Event::on(
Order::class,
Order::EVENT_AFTER_REMOVE_LINE_ITEM,
function(LineItemEvent $event) {
// @var LineItem $lineItem
$lineItem = $event->lineItem;
// @var bool $isNew
$isNew = $event->isNew;
// ...
}
);
EVENT_BEFORE_ADD_LINE_ITEM
- Type
- yii\base\Event
The event that is triggered before a new line item has been added to the order.
use craft\commerce\elements\Order;
use craft\commerce\models\LineItem;
use craft\commerce\events\AddLineItemEvent;
use yii\base\Event;
Event::on(
Order::class,
Order::EVENT_BEFORE_ADD_LINE_ITEM,
function(AddLineItemEvent $event) {
// @var LineItem $lineItem
$lineItem = $event->lineItem;
// @var bool $isNew
$isNew = $event->isNew;
// ...
}
);
EVENT_BEFORE_APPLY_ADD_NOTICE
- Type
- yii\base\Event
- Since
- 4.1.0
The event that is triggered before a notice has been added to the order.
use craft\commerce\elements\Order;
use craft\commerce\models\OrderNotice;
use craft\commerce\events\OrderNoticeEvent;
use yii\base\Event;
Event::on(
Order::class,
Order::EVENT_BEFORE_APPLY_ADD_NOTICE,
function(OrderNoticeEvent $event) {
// @var OrderNotice $orderNotice
$orderNotice = $event->orderNotice;
// ...
}
);
EVENT_BEFORE_COMPLETE_ORDER
- Type
- yii\base\Event
The event that is triggered before an order is completed.
use craft\commerce\elements\Order;
use yii\base\Event;
Event::on(
Order::class,
Order::EVENT_BEFORE_COMPLETE_ORDER,
function(Event $event) {
// @var Order $order
$order = $event->sender;
// ...
}
);
EVENT_BEFORE_LINE_ITEMS_REFRESHED
- Type
- yii\base\Event
- Since
- 5.1.0
The event that is triggered before line items are refreshed during recalculation of an order.
use craft\commerce\elements\Order;
use craft\commerce\events\OrderLineItemsRefreshEvent;
use yii\base\Event;
Event::on(
Order::class,
Order::EVENT_BEFORE_LINE_ITEMS_REFRESHED,
function(OrderLineItemsRefreshEvent $event) {
$event->lineItems = [];
$event->recalculate = true;
// ...
}
);