-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Fix "Confirmation request" email is sent on customer's newsletter unsubscribe action #15464
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
Conversation
…ubscription (issues/15218). Skip update customer subscribe status from save subscribe action from my account when nothing is changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR. I have added some comments with regards to language in the messages and also ease of understanding of the code.
->subscribeCustomerById($customerId); | ||
$subscribeStatus = $subscribeModel->getStatus(); | ||
if ($subscribeStatus == Subscriber::STATUS_SUBSCRIBED) { | ||
$this->messageManager->addSuccess(__('We saved the subscription.')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be tempted to update these messaged if they are to be shown to a user. Something like "We have saved your subscription." to make it a bit more personal to the user.
if ($subscribeStatus == Subscriber::STATUS_SUBSCRIBED) { | ||
$this->messageManager->addSuccess(__('We saved the subscription.')); | ||
} else { | ||
$this->messageManager->addSuccess(__('The confirmation request has been sent.')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest that this should be "A confirmation request has been sent." here.
} else { | ||
$this->subscriberFactory->create() | ||
->unsubscribeCustomerById($customerId); | ||
$this->messageManager->addSuccess(__('We removed the subscription.')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again to make this a bit more personal I would suggest "We have removed your newsletter subscription". You could maybe drop the newsletter part from the text and in which case. "We have removed your subscription" would be fine.
} else { | ||
$this->subscriberFactory->create()->unsubscribeCustomerById($customerId); | ||
$this->messageManager->addSuccess(__('We removed the subscription.')); | ||
$this->messageManager->addSuccess(__('We updated the subscription.')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again to make it more personal to the user "We have updated your subscription" would be good here.
@@ -84,7 +85,7 @@ public function testSaveActionRemoveSubscription() | |||
* Check that success message | |||
*/ | |||
$this->assertSessionMessages( | |||
$this->equalTo(['We removed the subscription.']), | |||
$this->equalTo(['We updated the subscription.']), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would need to update this message to related to the changes to the messages I have suggested.
->getIsSubscribed(); | ||
$isSubscribedParam = (boolean)$this->getRequest() | ||
->getParam('is_subscribed', false); | ||
if ($isSubscribedParam != $isSubscribedState) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it not work to do a !== comparison here?
if ((boolean)$this->getRequest()->getParam('is_subscribed', false)) { | ||
$this->subscriberFactory->create()->subscribeCustomerById($customerId); | ||
$this->messageManager->addSuccess(__('We saved the subscription.')); | ||
$isSubscribedState = $customer->getExtensionAttributes() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole section is still a bit hard to read/understand do you think that there would be a way to make it a bit easier to read? Maybe moving some of the logic to new private methods and splitting out some of the if/else so it is not so nested. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @dmanners
Thats a reasonable proposition, cause I agree that this part of newsletter module is not the best, but for now I will leave it as it is. If I will find enough time I will come back to it later.
…ewsletter unsubscribe action #15464
Hi @nuzil. Thank you for your contribution. Please, consider to port this solution to 2.3 release line. |
Description
This fix related to #15218
Skip update customer subscribe status from save subscribe action from my account when nothing is changed.
Fixed Issues (if relevant)
Manual testing scenarios
Contribution checklist