CustomerBehavior

Type
Class
Namespace
craft\commerce\behaviors
Inherits
craft\commerce\behaviors\CustomerBehavior » yii\base\Behavior (opens new window) » yii\base\BaseObject (opens new window)
Implements
yii\base\Configurable (opens new window)
Since
4.0

Customer behavior.

View source (opens new window)

# Public Properties

# activeCarts

Type
array (opens new window)
Default value
null

View source (opens new window)

# addresses

Type
craft\elements\Address (opens new window)
Default value
null

View source (opens new window)

# inactiveCarts

Type
array (opens new window)
Default value
null

View source (opens new window)

# orders

Type
craft\commerce\elements\Order[]
Default value
null

View source (opens new window)

# owner

Type
craft\elements\User (opens new window)
Default value
null

View source (opens new window)

# primaryBillingAddress

Type
null (opens new window), craft\elements\Address (opens new window)
Default value
null

View source (opens new window)

# primaryBillingAddressId

Type
null (opens new window), integer (opens new window)
Default value
null

View source (opens new window)

# primaryPaymentSource

Type
null (opens new window), craft\commerce\models\PaymentSource
Default value
null

View source (opens new window)

# primaryPaymentSourceId

Type
null (opens new window), integer (opens new window)
Default value
null

View source (opens new window)

# primaryShippingAddress

Type
null (opens new window), craft\elements\Address (opens new window)
Default value
null

View source (opens new window)

# primaryShippingAddressId

Type
null (opens new window), integer (opens new window)
Default value
null

View source (opens new window)

# subscriptions

Type
craft\commerce\elements\Subscription[]
Default value
null

View source (opens new window)

# Public Methods

Method Description
__call() (opens new window) Calls the named method which is not a class method.
__construct() (opens new window) Constructor.
__get() (opens new window) Returns the value of an object property.
__isset() (opens new window) Checks if a property is set, i.e. defined and not null.
__set() (opens new window) Sets value of an object property.
__unset() (opens new window) Sets an object property to null.
afterSaveUserHandler()
attach() Attaches the behavior object to the component.
canGetProperty() (opens new window) Returns a value indicating whether a property can be read.
canSetProperty() (opens new window) Returns a value indicating whether a property can be set.
className() (opens new window) Returns the fully qualified name of this class.
detach() (opens new window) Detaches the behavior object from the component.
events() Declares event handlers for the owner's events.
getActiveCarts()
getInactiveCarts()
getOrders() Returns the completed order elements associated with this user.
getPrimaryBillingAddress()
getPrimaryBillingAddressId()
getPrimaryPaymentSource()
getPrimaryPaymentSourceId()
getPrimaryShippingAddress()
getPrimaryShippingAddressId()
getSubscriptions() Returns the subscription elements associated with this customer.
hasMethod() (opens new window) Returns a value indicating whether a method is defined.
hasProperty() (opens new window) Returns a value indicating whether a property is defined.
init() (opens new window) Initializes the object.
setPrimaryBillingAddressId()
setPrimaryPaymentSourceId()
setPrimaryShippingAddressId()

# afterSaveUserHandler()

View source (opens new window)

Arguments

Returns

void

Throws

# attach()

Attaches the behavior object to the component.

The default implementation will set the owner property and attach event handlers as declared in events(). Make sure you call the parent implementation if you override this method.

View source (opens new window)

Arguments

# events()

Declares event handlers for the owner's events.

Child classes may override this method to declare what PHP callbacks should be attached to the events of the owner component.

The callbacks will be attached to the owner's events when the behavior is attached to the owner; and they will be detached from the events when the behavior is detached from the component.

The callbacks can be any of the following:

  • method in this behavior: 'handleClick', equivalent to [$this, 'handleClick']
  • object method: [$object, 'handleClick']
  • static method: ['Page', 'handleClick']
  • anonymous function: function ($event) { ... }

The following is an example:

[
    Model::EVENT_BEFORE_VALIDATE => 'myBeforeValidate',
    Model::EVENT_AFTER_VALIDATE => 'myAfterValidate',
]

View source (opens new window)

Returns

array (opens new window) – Events (array keys) and the corresponding event handler methods (array values).

# getActiveCarts()

View source (opens new window)

Returns

array (opens new window)

Throws

# getInactiveCarts()

View source (opens new window)

Returns

array (opens new window)

Throws

# getOrders()

Returns the completed order elements associated with this user.

Orders are returned with the most recent first.

View source (opens new window)

Returns

craft\commerce\elements\Order[]

# getPrimaryBillingAddress()

View source (opens new window)

Returns

craft\elements\Address (opens new window), null (opens new window)

# getPrimaryBillingAddressId()

View source (opens new window)

Returns

integer (opens new window), null (opens new window)

# getPrimaryPaymentSource()

Since
4.2

View source (opens new window)

Returns

craft\commerce\models\PaymentSource, null (opens new window)

Throws

# getPrimaryPaymentSourceId()

Since
4.2

View source (opens new window)

Returns

integer (opens new window), null (opens new window)

Throws

# getPrimaryShippingAddress()

View source (opens new window)

Returns

craft\elements\Address (opens new window), null (opens new window)

# getPrimaryShippingAddressId()

View source (opens new window)

Returns

integer (opens new window), null (opens new window)

# getSubscriptions()

Returns the subscription elements associated with this customer.

View source (opens new window)

Returns

craft\commerce\elements\Subscription[]

# setPrimaryBillingAddressId()

View source (opens new window)

Arguments

# setPrimaryPaymentSourceId()

Since
4.2

View source (opens new window)

Arguments

Returns

void

# setPrimaryShippingAddressId()

View source (opens new window)

Arguments