Skip to content
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

Bring Mailers from Spree and make order shipped email translatable #5763

Merged
merged 10 commits into from
Aug 5, 2020

Conversation

luisramos0
Copy link
Contributor

@luisramos0 luisramos0 commented Jul 14, 2020

What? Why?

Closes #5686
and addresses point 2 in openfoodfoundation/wishlist#357

Move all needed mailers from spree_core to OFN.

This was we can now translate test email and order shipped email (this email still needs a better template, but that will be for next time).

What should we test?

Here we change the base_mailer so better verify email basics like order confirmation and order cancellation for example. Are they sent correctly? Is the data in the email correct? Is the invoice email sent correctly?
Test the emails that were changed:

  • test email - is this email sent when the button pressed in the backoffice mail settings?
  • shipped email - is this email sent when order is marked as shipped? Any errors in the old un-styled template?

Release notes

Changelog Category: Changed
Brought test and shipment emails from Spree. Order Shipped email is now translatable!

@luisramos0 luisramos0 self-assigned this Jul 14, 2020
@luisramos0 luisramos0 changed the title Mailers Bring Mailers from Spree and make order shipped email translatable Jul 14, 2020
- if @shipment.tracking_url
= Spree.t('shipment_mailer.shipped_email.track_link', url: @shipment.tracking_url)

= Spree.t('shipment_mailer.shipped_email.thanks')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure switching from .text to .HTML won't break things? I never investigated this but I think .text is used as a fallback text-version of the email for specific old mail servers/clients. Again, no idea about how it works.

Copy link
Contributor Author

@luisramos0 luisramos0 Jul 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spree emails are all text, and ofn's are html. So I think it's fine, from now on these will also be sent in html. Testing will validate that as well.

I think you are referring to something we could do which is to send html and text emails and the email client would use text as a fall back option. This is also good for deliverability but it's something we are not doing and is out of scope for this PR. Does this make sense to you?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood, I thought those text ones were just a fallback and not Spree's only templates 👍 Then, this means that those only-text emails saw Eugeni some time ago were a bug or they were missing an OFN template 🙈

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The emails seen by Eugeni are this shipment email. It was text in spree and after this PR it's html in OFN. But still without the normal OFN styling. That will need to be addressed in another PR.

@RachL
Copy link
Contributor

RachL commented Jul 29, 2020

OMG I'm just discovering this PR!!! Being able to translate this email is such a GOOOD news!!

Thanks @luisramos0 !!

@filipefurtad0 filipefurtad0 self-assigned this Jul 29, 2020
@filipefurtad0 filipefurtad0 added pr-staged-uk staging.openfoodnetwork.org.uk and removed pr-staged-uk staging.openfoodnetwork.org.uk labels Jul 29, 2020
@luisramos0
Copy link
Contributor Author

I know!! :-)

@filipefurtad0 filipefurtad0 added the pr-staged-uk staging.openfoodnetwork.org.uk label Jul 30, 2020
@filipefurtad0
Copy link
Contributor

filipefurtad0 commented Jul 30, 2020

Hi @luisramos0,

Triggered the following emails, before and after the PR:

Test
Order shipped
Confirm Account
Welcome to OFN
Reset Password
Send Invoice
Order Confirmation
Order Cancellation

  • Test emails

Before

image

After

image

  • Order shipped Emails

Before

image

After

image

  • Confirm Account Email - OK, before and after

  • Welcome to OFN Email - OK, before and after

  • Reset Password Email - OK, before and after

  • Send Invoice (pdf per email) - OK, before and after

  • Order Confirmation emails

These seem to be broken after this PR. I checked this both by clicking "Resend" or "Resend Confirmation" in the backoffice, and in both in this case, the user sees:

image

After placing a new order, neither the Hub nor the customer receive confirmation email. This is a silent error, no snail seen. Check Bugsnag errors for details:

https://app.bugsnag.com/yaycode/openfoodnetwork-uk/errors/5f228433c37fb80018f09297

  • Order cancellation emails are also broken, after this PR

image

The changes introduced by the PR work fine, but order confirmation/cancellation emails are quite a critical, so perhaps best not to introduce these in the code, right? I'm moving the PR back to In Dev for a second look.

Some Updates:

  • Findings above were double checked on staging-FR
  • Order confirmation emails from a placed order (staging-UK) arrived for both hub and customer, about 2hrs after this test was made.

Also, a product question maybe @RachL @lin-d-hop : I'm not sure what's the difference between the two buttons (pic below). "Resend Confirmation" triggers the modal asking for confirmation but other than that, is there a difference in function?

image

@filipefurtad0 filipefurtad0 added pr-staged-uk staging.openfoodnetwork.org.uk pr-staged-fr staging.coopcircuits.fr and removed pr-staged-uk staging.openfoodnetwork.org.uk pr-staged-fr staging.coopcircuits.fr labels Jul 30, 2020
@RachL
Copy link
Contributor

RachL commented Jul 30, 2020

Also, a product question maybe @RachL @lin-d-hop : I'm not sure what's the difference between the two buttons (pic below). "Resend Confirmation" triggers the modal asking for confirmation but other than that, is there a difference in function?

Yes I've always wondered as well. 🤷

@filipefurtad0
Copy link
Contributor

In that case, maybe we could consider removing one of them, maybe as a papercut - if appropriate.

The "Resend Confirmation" button has a more descriptive naming and already has the associated modal, which is also helpful I think, so we could keep this one. Thoughts?

@RachL
Copy link
Contributor

RachL commented Jul 30, 2020

Sounds good 👍 Let's re-test maybe just to see if it is really 100% the same? Maybe you already did?

@filipefurtad0
Copy link
Contributor

Yes, I found no difference - the emails looked identical, but I'd wait for feedback from core Devs as well. Perhaps @luisramos0 and/or reviewers can confirm that the code behind these features is the same?

@luisramos0
Copy link
Contributor Author

yes, the code is the same behind both resends 👍

Thanks for testing Filipe, I cant replicate that error locally. It's a tricky one related to class loading I think because the "missing method" is there and included as part of one of the helper classes... it should work.

I'll have to come back to this later.

@filipefurtad0
Copy link
Contributor

Thanks for your feedback @luisramos0.

The snail-errors were reproducible in staging environments (UK and FR). But thinking of it now, I am not entirely sure the PR broke the order confirmation emails as well, or they just got queued after the snail errors. Maybe testing in a different order would result in a different outcome. I'll try this and provide some additional feedback.

Thanks as well for confirming the code on the "Resend" button 👍
Opened an Enhancement/Papercut #5850 on this regard.

@filipefurtad0 filipefurtad0 added the pr-staged-uk staging.openfoodnetwork.org.uk label Jul 31, 2020
@filipefurtad0
Copy link
Contributor

I did a quick double-checked now:
Order confirmation emails trigger a bugsnag error as well, and don't arrive the mailbox. This happens also after placing an order immediately after staging the PR, so it appears independent of those errors seen by the user (order cancelling and resend confirmation).

@filipefurtad0 filipefurtad0 removed the pr-staged-uk staging.openfoodnetwork.org.uk label Jul 31, 2020
…he required ::CheckoutHelper in OFN

The OFN checkoutHelper was not being included and instead the Spree::CheckoutHelper, that doesnt have the necessary helpers, was used
@luisramos0
Copy link
Contributor Author

ok, this was easier than I thought. Yes, there was a bug in the code. There's Spree::CheckoutHelper in Spree that was hidden our CheckoutHelper. I managed to replicate the problem you describe, I pushed a new simple commit (no need for code review) and I restaged the PR. The problem is now gone. This is ready for testing again 👍

…xt and is now html

This template needs to be revisited, this is just a quick fix
@luisramos0
Copy link
Contributor Author

In staging I got the shipment email like this:
image

So I added some paragraphs and breaklines to the template so it doesnt happen again.
We need to revisit this email template. I think we need a new issue to redo the shipment email template, like this one: #2910

@luisramos0
Copy link
Contributor Author

ok, the email now looks like this 👍

image

@RachL RachL self-assigned this Aug 5, 2020
@RachL
Copy link
Contributor

RachL commented Aug 5, 2020

I've re-tested them all:

  • Test : I'm not sure how to get the email. Should I turn one of my accounts as super admin?
  • Order shipped ✅
  • Confirm Account ✅
  • Welcome to OFN ✅
  • Reset Password ✅
  • Send Invoice ✅
  • Order Confirmation ✅
  • Order Cancellation ✅

As all email works perfectly, I'm moving this to ready to go!

@RachL RachL removed the pr-staged-es label Aug 5, 2020
@RachL
Copy link
Contributor

RachL commented Aug 5, 2020

Nevermind: I found how to test the test email :)

image

@luisramos0 luisramos0 merged commit f093656 into openfoodfoundation:master Aug 5, 2020
@luisramos0 luisramos0 deleted the mailers branch August 5, 2020 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ByeBye Spree] Move Mailers to OFN
5 participants