Skip to content

LineItemStatuses ​

Type
Class
Namespace
craft\commerce\services
Inherits
craft\commerce\services\LineItemStatuses » yii\base\Component » yii\base\BaseObject
Implements
yii\base\Configurable
Since
2.0

Order status service.

View source

Public Properties ​

PropertyDescription
allLineItemStatusescraft\commerce\models\LineItemStatus[], array – all Order Statuses
behaviorsyii\base\Behavior – List of behaviors attached to this component.
defaultLineItemStatuscraft\commerce\models\LineItemStatus, null – default line item status from the DB
defaultLineItemStatusIdnull, integer – default line item status ID from the DB

allLineItemStatuses ​

Type
craft\commerce\models\LineItemStatus[], array
Default value
null

all Order Statuses

View source

defaultLineItemStatus ​

Type
craft\commerce\models\LineItemStatus, null
Default value
null

default line item status from the DB

View source

defaultLineItemStatusId ​

Type
null, integer
Default value
null

default line item status ID from the DB

View source

Public Methods ​

MethodDescription
__call()Calls the named method which is not a class method.
__clone()This method is called after the object is created by cloning an existing one.
__construct()Constructor.
__get()Returns the value of a component property.
__isset()Checks if a property is set, i.e. defined and not null.
__set()Sets the value of a component property.
__unset()Sets a component property to be null.
_clearCaches()Clear all memoization
archiveLineItemStatusById()Archive an line item status by it's id.
attachBehavior()Attaches a behavior to this component.
attachBehaviors()Attaches a list of behaviors to the component.
behaviors()Returns a list of behaviors that this component should behave as.
canGetProperty()Returns a value indicating whether a property can be read.
canSetProperty()Returns a value indicating whether a property can be set.
className()Returns the fully qualified name of this class.
detachBehavior()Detaches a behavior from the component.
detachBehaviors()Detaches all behaviors from the component.
ensureBehaviors()Makes sure that the behaviors declared in behaviors() are attached to this component.
getAllLineItemStatuses()Returns all Order Statuses
getBehavior()Returns the named behavior object.
getBehaviors()Returns all behaviors attached to this component.
getDefaultLineItemStatus()Get default lineItem status from the DB
getDefaultLineItemStatusForLineItem()Get the default lineItem status for a particular lineItem. Defaults to the default lineItem status as configured in the control panel.
getDefaultLineItemStatusId()Get default lineItem status ID from the DB
getLineItemStatusByHandle()Get line item status by its handle.
getLineItemStatusById()Get a line item status by ID
handleArchivedLineItemStatus()Handle line item status being archived
handleChangedLineItemStatus()Handle line item status change.
hasEventHandlers()Returns a value indicating whether there is any handler attached to the named event.
hasMethod()Returns a value indicating whether a method is defined.
hasProperty()Returns a value indicating whether a property is defined for this component.
init()Initializes the object.
off()Detaches an existing event handler from this component.
on()Attaches an event handler to an event.
reorderLineItemStatuses()Reorders the line item statuses.
saveLineItemStatus()Save the line item status.
trigger()Triggers an event.

_clearCaches() ​

Since
3.2.5

Clear all memoization

View source

archiveLineItemStatusById() ​

Archive an line item status by it's id.

View source

Arguments ​

  • $id
  • $storeId

Throws ​

getAllLineItemStatuses() ​

Returns all Order Statuses

View source

Arguments ​

Returns ​

\Illuminate\Support\Collection<\craft\commerce\models\LineItemStatus>

Throws ​

getDefaultLineItemStatus() ​

Get default lineItem status from the DB

View source

Arguments ​

  • $storeId

getDefaultLineItemStatusForLineItem() ​

Get the default lineItem status for a particular lineItem. Defaults to the default lineItem status as configured in the control panel.

View source

Arguments ​

  • $lineItem

getDefaultLineItemStatusId() ​

Get default lineItem status ID from the DB

View source

Arguments ​

  • $storeId

getLineItemStatusByHandle() ​

Get line item status by its handle.

View source

Arguments ​

  • $handle
  • $storeId

getLineItemStatusById() ​

Get a line item status by ID

View source

Arguments ​

  • $id
  • $storeId

handleArchivedLineItemStatus() ​

Handle line item status being archived

View source

Arguments ​

  • $event

Throws ​

handleChangedLineItemStatus() ​

Handle line item status change.

View source

Arguments ​

  • $event

Throws ​

reorderLineItemStatuses() ​

Reorders the line item statuses.

View source

Arguments ​

  • $ids

Throws ​

saveLineItemStatus() ​

Save the line item status.

View source

Arguments ​

  • $lineItemStatus
  • $runValidation (boolean) – Should we validate this line item status before saving.

Throws ​

Constants ​

ConstantDescription
CONFIG_STATUSES_KEY

Events ​

EVENT_DEFAULT_LINE_ITEM_STATUS ​

Type
craft\commerce\events\DefaultLineItemStatusEvent

The event that is triggered when getting a default status for a line item. You may set craft\commerce\events\DefaultLineItemStatusEvent::$lineItemStatus to a desired LineItemStatus to override the default status set in control panel.

Plugins can get notified when a default line item status is being fetched

php
use craft\commerce\events\DefaultLineItemStatusEvent;
use craft\commerce\services\LineItemStatuses;
use yii\base\Event;

Event::on(LineItemStatuses::class, LineItemStatuses::EVENT_DEFAULT_LINE_ITEM_STATUS, function(DefaultLineItemStatusEvent $e) {
    // Perhaps determine a better default line item status than the one set in control panel
});