You are here

public function OrderAssignment::assign in Commerce Core 8.2

Assigns the order to the given customer.

Parameters

\Drupal\commerce_order\Entity\OrderInterface $order: The order.

\Drupal\user\UserInterface $customer: The customer.

bool $save_order: Whether the order should be saved.

Overrides OrderAssignmentInterface::assign

1 call to OrderAssignment::assign()
OrderAssignment::assignMultiple in modules/order/src/OrderAssignment.php
Assigns multiple orders to the given customer.

File

modules/order/src/OrderAssignment.php, line 44

Class

OrderAssignment

Namespace

Drupal\commerce_order

Code

public function assign(OrderInterface $order, UserInterface $customer, $save_order = TRUE) {

  // Notify other modules before the order is modified, so that
  // subscribers have access to the original data.
  $event = new OrderAssignEvent($order, $customer);
  $this->eventDispatcher
    ->dispatch(OrderEvents::ORDER_ASSIGN, $event);
  $order
    ->setCustomer($customer);
  $order
    ->setEmail($customer
    ->getEmail());
  if ($save_order) {
    $order
      ->save();
  }
}