-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unsubscribing via mailchimp unsubscribe link and resubscribing via Sylius throws an error #90
Comments
Hey! We have also been experiencing this error for some time. In reality, there is no "solution"!
try {
$this->client->subscribeEmail($audience, $email);
} catch (ClientException $clientException) {
if ($this->isContactDeletedOrUnsubscribedException($clientException)) {
return $this->json(
$this->translator->trans('setono_sylius_mailchimp.ui.already_subscribed', [
'{link}' => $this->getResubscribeAudienceFormLink($audience),
]),
422,
[$clientException->getMessage()],
);
}
throw $clientException;
} catch (\Throwable $t) {
return $this->json(
$this->translator->trans('setono_sylius_mailchimp.ui.generic_error'),
422,
[$t->getMessage()],
);
} private function isContactDeletedOrUnsubscribedException(ClientException $clientException): bool
{
if ($clientException->getStatusCode() !== 400) {
return false;
}
// Deleted contacts
if (str_starts_with($clientException->getMessage(), 'Forgotten Email Not Subscribed:')) {
return true;
}
// Unsubscribed contacts
if (str_starts_with($clientException->getMessage(), 'Member In Compliance State:')) {
return true;
}
return false;
}
|
Appreciate your answer and solution @lruozzi9. I understand these boundaries come from Mailchimp. Your approach sounds like a viable workaround. |
User Story
No. 1: As a newsletter subscriber, I want to unsubscribe via the link in a Mailchimp mail in the footer, as it is easier than logging into the shop account of the given vendor.
No. 2: As the same customer, I may want to subscribe to the newsletter again within Sylius shop, as I changed my mind.
Problem
unsubscribing via the Mailchimp link in the footer and subscribing again via Sylius throws an error
Mailchimp error: {"message":"Response status is 400 instead of subscribed.","response":{"title":"Member In Compliance State","status":400,"detail":"[email protected] is in a compliance state due to unsubscribe, bounce, or compliance review and cannot be subscribed."
Suggested solution
this Stackoverflow thread suggests to first check and change the user status on Mailchimp before attempting to change the user's subscription state
https://stackoverflow.com/questions/42990336/mailchimp-how-can-i-tell-if-a-user-has-unsubscribed-themselves
The text was updated successfully, but these errors were encountered: