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

# allLineItemStatuses

Type
craft\commerce\models\LineItemStatus[]
Access
Read-only

View source

# defaultLineItemStatus

Type
craft\commerce\models\LineItemStatus, null
Access
Read-only

View source

# defaultLineItemStatusId

Type
integer, null
Access
Read-only

View source

# Public Methods

Method Description
__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.
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 CP configured default lineItem status.
getDefaultLineItemStatusId() Get default lineItem status ID from the DB
getLineItemStatusByHandle() Get line item status by its handle.
getLineItemStatusById() Get an 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.

# archiveLineItemStatusById()

Archive an line item status by it's id.

View source

Arguments

Returns

boolean

Throws

# getAllLineItemStatuses()

Returns all Order Statuses

View source

Returns

craft\commerce\models\LineItemStatus[]

# getDefaultLineItemStatus()

Get default lineItem status from the DB

View source

Returns

craft\commerce\models\LineItemStatus, null

# getDefaultLineItemStatusForLineItem()

Get the default lineItem status for a particular lineItem. Defaults to the CP configured default lineItem status.

View source

Arguments

Returns

craft\commerce\models\LineItemStatus, null

# getDefaultLineItemStatusId()

Get default lineItem status ID from the DB

View source

Returns

integer, null

# getLineItemStatusByHandle()

Get line item status by its handle.

View source

Arguments

Returns

craft\commerce\models\LineItemStatus, null

# getLineItemStatusById()

Get an line item status by ID

View source

Arguments

Returns

craft\commerce\models\LineItemStatus, null

# handleArchivedLineItemStatus()

Handle line item status being archived

View source

Arguments

Returns

void

Throws

# handleChangedLineItemStatus()

Handle line item status change.

View source

Arguments

Returns

void

Throws

# reorderLineItemStatuses()

Reorders the line item statuses.

View source

Arguments

Returns

boolean

Throws

# saveLineItemStatus()

Save the line item status.

View source

Arguments

Returns

boolean

Throws

# Constants

Constant Description
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 CP

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

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) {
    // Do something - perhaps figure out a better default line item status than the one set in CP
});