Skip to content

Commit

Permalink
feat: use user id instead of the email
Browse files Browse the repository at this point in the history
  • Loading branch information
mastudillot committed Aug 1, 2024
1 parent bd89b4a commit cb64b41
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -717,8 +717,8 @@ private function getTotalAmountFromOrder(WC_Order $order): int
private function validatePayerMatchesCardInscription(WC_Payment_Token_Oneclick $paymentToken): bool
{
$currentUser = wp_get_current_user();
$userEmail = $currentUser->user_email;
$inscriptionEmail = $paymentToken->get_email();
$userEmail = $currentUser->id;
$inscriptionEmail = $paymentToken->get_userId();

return $userEmail == $inscriptionEmail;
}
Expand Down
12 changes: 12 additions & 0 deletions plugin/src/Tokenization/WC_Payment_Token_Oneclick.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,16 @@ public function set_email($email)
{
$this->set_prop('email', $email);
}

/**
* Returns the user id of the inscriptions.
*
* @param string $context What the value is for. Valid values are view and edit.
*
* @return int The user id.
*/
public function get_userId($context = 'view')
{
return $this->get_prop('user_id', $context);
}
}

0 comments on commit cb64b41

Please sign in to comment.