Skip to content

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

Merged
merged 5 commits into from
Jul 3, 2018

Conversation

nuzil
Copy link
Contributor

@nuzil nuzil commented May 23, 2018

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)

  1. Skip update customer subscribe status from save subscribe action from my account when nothing is changed.

Manual testing scenarios

  1. Activate "Need to Confirm" for the newsletter subscription
  2. Register a new customer
  3. Subscribe to the newsletter
  4. Confirm the newsletter subscription.
  5. Login as created customer
  6. Unsubscribe from the newsletter from the customer area

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

…ubscription (issues/15218). Skip update customer subscribe status from save subscribe action from my account when nothing is changed.
Copy link
Contributor

@dmanners dmanners left a 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.'));
Copy link
Contributor

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.'));
Copy link
Contributor

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.'));
Copy link
Contributor

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.'));
Copy link
Contributor

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.']),
Copy link
Contributor

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) {
Copy link
Contributor

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()
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@magento-engcom-team
Copy link
Contributor

Hi @nuzil. Thank you for your contribution.
We will aim to release these changes as part of 2.2.6.
Please check the release notes for final confirmation.

Please, consider to port this solution to 2.3 release line.
You may use Porting tool to port commits automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants