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

Add a 'reply to' email address to some more emails #13176

Merged

Conversation

drummer83
Copy link
Contributor

What? Why?

This builds on top of #13139 and follows the discussion here.

The following should be changed by this PR:

  1. The 'authorize payment' email has the customer's email as reply to address.
  2. The 'order confirmation' email for shops has the customer's email as reply to address.
  3. The 'order cancellation' email for shops has the customer's email as reply to address.

What should we test?

  • Check that the reply to address has been added as mentioned above.
  • Check that the content of the emails is unchanged.

Release notes

Changelog Category (reviewers may add a label for the release notes):

  • User facing changes
  • API changes (V0, V1, DFC or Webhook)
  • Technical changes only
  • Feature toggled

The title of the pull request will be included in the release notes.

Dependencies

Documentation updates

Sorry, something went wrong.

@drummer83 drummer83 added the user facing changes Thes pull requests affect the user experience label Feb 25, 2025
@drummer83 drummer83 self-assigned this Feb 25, 2025
@drummer83 drummer83 force-pushed the reply-to-email-address_part2 branch from 4652553 to 71fa0f0 Compare March 18, 2025 15:07
@drummer83 drummer83 marked this pull request as ready for review March 18, 2025 15:19
Comment on lines 20 to 27
shop_owner = @payment.order.distributor.owner
@order = @payment.order
shop_owner = @order.distributor.owner
subject = I18n.t('spree.payment_mailer.authorization_required.subject',
order: @payment.order)
order: @order)
I18n.with_locale valid_locale(shop_owner) do
mail(to: shop_owner.email,
subject:)
subject:,
reply_to: @order.email)
Copy link
Member

Choose a reason for hiding this comment

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

In Ruby, the @var notation refers to instance variables that are available beyond the method in which they are defined. So in controllers they are often defined to be used in the views. And here, @payment can be used in the email template.

The new variable @order however, is not used in the template. It's only used for translating the subject and the reply_to field. So you can turn this into a normal local variable. Other developers then know that it's not used beyond this scope.

I'll add a commit to show you what I mean.

@payment = payment
@order = @payment.order
@order = payment.order
Copy link
Member

Choose a reason for hiding this comment

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

Now looking at the views, I found that they were only referring to the order, not the payment. So instead of making order a local variable, I removed @payment as variable and changed the views to access @order directly.

Copy link
Member

@dacook dacook left a comment

Choose a reason for hiding this comment

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

Nice work 👍

@filipefurtad0 filipefurtad0 self-assigned this Mar 25, 2025
@filipefurtad0 filipefurtad0 added the pr-staged-au staging.openfoodnetwork.org.au label Mar 25, 2025
@filipefurtad0
Copy link
Contributor

filipefurtad0 commented Mar 25, 2025

Hey @drummer83 ,

Thanks! I could verify in staging that the emails you've changed arrive and display the reply-to email address of the customer:

Payment Authorization (Subscription)

image

Order Confirmation

image

Order Cancellation (Hub)

image

Merging!

PS: One comment, I'm a bit surprised that these changes to emails trigger no failures on automated tests. One one side of things, it's a good sign 😅 on another perspective, might mean we're a bit short on coverage here. I guess the reason is we're adding reply_to addresses, and not changing these.
In any case, I had a look, and it seems we're only covering reply-to emails here and here. Maybe something to keep our 👀 on and improve at some point?

@filipefurtad0 filipefurtad0 merged commit 2a3927c into openfoodfoundation:master Mar 25, 2025
35 checks passed
@filipefurtad0 filipefurtad0 removed the pr-staged-au staging.openfoodnetwork.org.au label Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
user facing changes Thes pull requests affect the user experience
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants