You are here

public function CartEventSubscriber::onOrderAssign in Commerce Combine Carts 8

React when an order is being assigned to a user.

Parameters

\Drupal\commerce_order\Event\OrderAssignEvent $event: The event.

Throws

\Drupal\Core\Entity\EntityStorageException

File

src/EventSubscriber/CartEventSubscriber.php, line 47

Class

CartEventSubscriber
Class CartEventSubscriber

Namespace

Drupal\commerce_combine_carts\EventSubscriber

Code

public function onOrderAssign(OrderAssignEvent $event) {
  $order = $event
    ->getOrder();
  if (!$order
    ->get('cart')
    ->isEmpty() && $order
    ->get('cart')->value) {
    $this->cartUnifier
      ->assignCart($order, $event
      ->getCustomer());
  }
}