Skip to content

Commit

Permalink
fix newsllatter subscription
Browse files Browse the repository at this point in the history
  • Loading branch information
gheorghelupu17 committed Nov 7, 2024
1 parent f7ea946 commit 05ddcc1
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions app/Services/NewsletterService.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ class NewsletterService
{
public static function subscribe(string $email, ?string $name = null)
{
$mergeFields = [
'MERGE1' => $name,
];
$mergeFields = [];
if (filled($name))
{
$mergeFields = [
'MERGE1' => $name,
];

}
$response = rescue(
fn () => Newsletter::subscribe($email, $mergeFields),
false
Expand All @@ -24,11 +28,11 @@ public static function subscribe(string $email, ?string $name = null)
Log::error('Failed to subscribe user to newsletter', [
'email' => $email,
'response' => $response,
'error' => Newsletter::getApi()->getLastError(),
]);

// TODO: check if email registered as user
// and assign subscriber badge if the
// user doesn't already have one.

}

return $response;
Expand Down

0 comments on commit 05ddcc1

Please sign in to comment.