Skip to content

Commit

Permalink
Merge branch '1.x' into bugfix/proxy-element-card-styles
Browse files Browse the repository at this point in the history
  • Loading branch information
i-just committed Nov 19, 2024
2 parents f0c06a5 + 8acb870 commit 7946f5d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@

- Fixed a styling issue with the element’s `.proxy-element-card` meta card footer.

## 1.2.0.2 - 2024-11-08

- Fixed a PHP error that could occur when saving a new user.

## 1.2.0.1 - 2024-11-07

- Fixed an infinite loop that could occur when querying for a user.

## 1.2.0 - 2024-11-06

> [!NOTE]
Expand Down
15 changes: 7 additions & 8 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -575,15 +575,15 @@ function(DefineMenuItemsEvent $event) {
private function handleUserElementChanges(): void
{
// if email address got changed - update stripe
Event::on(UserRecord::class, UserRecord::EVENT_BEFORE_UPDATE, function(ModelEvent $event) {
$userRecord = $event->sender;
Event::on(User::class, User::EVENT_BEFORE_SAVE, function(ModelEvent $event) {
/** @var User|StripeCustomerBehavior $user */
$user = Craft::$app->getUsers()->getUserById($userRecord->id);
$user = $event->sender;
$userRecord = UserRecord::findOne($user->id);
$settings = $this->getSettings();
if ($user->isCredentialed && $settings['syncChangedUserEmailsToStripe']) {
$oldEmail = $userRecord->getOldAttribute('email');
$newEmail = $userRecord->getAttribute('email');
if ($oldEmail != $newEmail) {
if ($userRecord && $user->isCredentialed && $settings['syncChangedUserEmailsToStripe']) {
$oldEmail = $userRecord->getAttribute('email');
$newEmail = $user->email;
if ($oldEmail && $newEmail && ($oldEmail != $newEmail)) {
$customers = $user->getStripeCustomers();
if ($customers->isNotEmpty()) {
$client = $this->getApi()->getClient();
Expand Down Expand Up @@ -671,7 +671,6 @@ public function getCpNavItem(): ?array
];
}


return $ret;
}

Expand Down

0 comments on commit 7946f5d

Please sign in to comment.