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.
Public Properties ​
| Property | Description |
|---|---|
| allLineItemStatuses | craft\commerce\models\LineItemStatus[], array – all Order Statuses |
| behaviors | yii\base\Behavior – List of behaviors attached to this component. |
| defaultLineItemStatus | craft\commerce\models\LineItemStatus, null – default line item status from the DB |
| defaultLineItemStatusId | null, integer – default line item status ID from the DB |
allLineItemStatuses ​
- Type
- craft\commerce\models\LineItemStatus[], array
- Default value
null
all Order Statuses
defaultLineItemStatus ​
- Type
- craft\commerce\models\LineItemStatus, null
- Default value
null
default line item status from the DB
defaultLineItemStatusId ​
default line item status ID from the DB
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. |
| _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
archiveLineItemStatusById() ​
Archive an line item status by it's id.
Arguments ​
$id$storeId
Throws ​
getAllLineItemStatuses() ​
Returns all Order Statuses
Arguments ​
Returns ​
\Illuminate\Support\Collection<\craft\commerce\models\LineItemStatus>
Throws ​
getDefaultLineItemStatus() ​
Get default lineItem status from the DB
Arguments ​
$storeId
getDefaultLineItemStatusForLineItem() ​
Get the default lineItem status for a particular lineItem. Defaults to the default lineItem status as configured in the control panel.
Arguments ​
$lineItem
getDefaultLineItemStatusId() ​
Get default lineItem status ID from the DB
Arguments ​
$storeId
getLineItemStatusByHandle() ​
Get line item status by its handle.
Arguments ​
$handle$storeId
getLineItemStatusById() ​
Get a line item status by ID
Arguments ​
$id$storeId
handleArchivedLineItemStatus() ​
Handle line item status being archived
Arguments ​
$event
Throws ​
- Throwable
if reasons
handleChangedLineItemStatus() ​
Handle line item status change.
Arguments ​
$event
Throws ​
- Throwable
if reasons
reorderLineItemStatuses() ​
Reorders the line item statuses.
Arguments ​
$ids
Throws ​
- yii\base\Exception
- yii\base\ErrorException
- yii\base\NotSupportedException
- yii\web\ServerErrorHttpException
saveLineItemStatus() ​
Save the line item status.
Arguments ​
$lineItemStatus$runValidation(boolean) – Should we validate this line item status before saving.
Throws ​
Constants ​
| Constant | Description |
|---|---|
CONFIG_STATUSES_KEY |
Events ​
EVENT_DEFAULT_LINE_ITEM_STATUS ​
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
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
});