You are here

public function Order::getCustomer in Commerce Core 8.2

Gets the customer user.

Return value

\Drupal\user\UserInterface The customer user entity. If the order is anonymous (customer unspecified or deleted), an anonymous user will be returned. Use $customer->isAnonymous() to check.

Overrides OrderInterface::getCustomer

1 call to Order::getCustomer()
Order::preSave in modules/order/src/Entity/Order.php
Acts on an entity before the presave hook is invoked.

File

modules/order/src/Entity/Order.php, line 163

Class

Order
Defines the order entity class.

Namespace

Drupal\commerce_order\Entity

Code

public function getCustomer() {
  $customer = $this
    ->get('uid')->entity;

  // Handle deleted customers.
  if (!$customer) {
    $customer = User::getAnonymousUser();
  }
  return $customer;
}