Skip to content

Commit

Permalink
cautious user assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeholder committed Sep 30, 2024
1 parent 3c60752 commit be857b5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/services/OrderHistories.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,16 @@ public function createOrderHistoryFromOrder(Order $order, ?int $oldStatusId): bo
$userId = $currentUser->id;
}

$user = Craft::$app->getUsers()->getUserById($userId);
if ($userId) {
$user = Craft::$app->getUsers()->getUserById($userId);
if($user) {
$orderHistoryModel->userId = $userId;
$orderHistoryModel->userName = $user->fullName ?? $user->getEmail();

Check failure on line 127 in src/services/OrderHistories.php

View workflow job for this annotation

GitHub Actions / ci / Code Quality / PHPStan / PHPStan

Call to an undefined method craft\elements\User::getEmail().
}else{
$orderHistoryModel->userName = $order->getEmail();
}
}

$orderHistoryModel->userId = $userId;
$orderHistoryModel->userName = $user?->fullName ?? $user?->email;
$orderHistoryModel->message = $order->message;

if (!$this->saveOrderHistory($orderHistoryModel)) {
Expand Down

0 comments on commit be857b5

Please sign in to comment.