You are here

public function TimestampEventSubscriber::onPlaceTransition in Commerce Core 8.2

Sets the order's placed timestamp.

Parameters

\Drupal\state_machine\Event\WorkflowTransitionEvent $event: The transition event.

File

modules/order/src/EventSubscriber/TimestampEventSubscriber.php, line 45

Class

TimestampEventSubscriber

Namespace

Drupal\commerce_order\EventSubscriber

Code

public function onPlaceTransition(WorkflowTransitionEvent $event) {

  /** @var \Drupal\commerce_order\Entity\OrderInterface $order */
  $order = $event
    ->getEntity();
  if (empty($order
    ->getPlacedTime())) {
    $order
      ->setPlacedTime($this->time
      ->getRequestTime());
  }
}