order_id = $order_id; $this->old_status = $old_status; $this->new_status = $new_status; try { $this->occurred_at = ! empty( $occurred_at ) ? new \DateTimeImmutable( $occurred_at, wp_timezone() ) : new \DateTimeImmutable( 'now', wp_timezone() ); } catch ( \Exception $exception ) { $this->occurred_at = new \DateTimeImmutable( 'now', wp_timezone() ); } } /** * {@inheritdoc} */ public function getName(): string { return self::NAME; } /** * {@inheritdoc} */ public function getPayload(): array { return array( 'order_id' => $this->order_id, 'old_status' => $this->old_status, 'new_status' => $this->new_status, ); } /** * {@inheritdoc} */ public function getOccurredAt(): \DateTimeImmutable { return $this->occurred_at; } /** * Get order ID. * * @return int */ public function getOrderId(): int { return $this->order_id; } /** * Get old status. * * @return string */ public function getOldStatus(): string { return $this->old_status; } /** * Get new status. * * @return string */ public function getNewStatus(): string { return $this->new_status; } }