Invoice email is sent twice

Created on 21 November 2022, over 2 years ago
Updated 24 January 2023, over 2 years ago

Problem/Motivation

When order / invoice payment is done after the order has been placed, the invoice email is sent out twice (once at confirmation and another time when marked as fully paid) due to changes introduced with #3257231: No email is sent to customer .

Steps to reproduce

Place an order using manual or on-site payment. Later mark the order or the invoice as fully paid.

Proposed resolution

Introduce a way to save the information about whether the invoice email has been sent yet and check that information before spooling invoices for mailing.

Remaining tasks

Find an elegant solution 😬...

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇦🇹Austria attisan Vienna

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States tkiehne

    Could this be related to 🐛 Order onPaid event called twice RTBC ?

  • First commit to issue fork.
  • @sadysierralta opened merge request.
  • Status changed to Needs review about 2 years ago
  • Status changed to RTBC about 2 years ago
  • Seems working as expected & this implementation will allow any more complex isolated logic in future if needed.
    LGTM!

  • 🇮🇱Israel jsacksick

    Potentially a duplicate of 🐛 mail attachment not included Closed: won't fix , perhaps we should consider queueing the email too, will come back to this either later today or on Friday.

  • 🇮🇹Italy afagioli Rome

    From my live experience, this double send (once at confirmation and another time when marked as fully paid) is not an issue.
    On different scenario, I understand it may be.

    Shall we need one more checkbox inside "/admin/commerce/config/invoice-types/TYPE/edit" > Emails ?

    NOW:
      [ ]  Email the customer a confirmation when an invoice is "confirmed" or paid
    
    THEN:
      [ ]  Email the customer a confirmation when an invoice is confirmed 
      [ ]  Email the customer a confirmation when an invoice is paid
    
  • 🇮🇱Israel jsacksick

    From my live experience, this double send (once at confirmation and another time when marked as fully paid) is not an issue.
    On different scenario, I understand it may be.

    In some cases, it might make sense to send it twice... The invoice status might affect the invoice content, for example a "Paid" mention could be appended.

    Having different checkboxes wouldn't really help as it could be the email should still be sent on both transitions, and some invoices could be sent on confirm, others on paid?

    I was actually starting to fix this, but now having second thoughts..

  • 🇮🇱Israel jsacksick

    Since this was reported in 🐛 mail attachment not included Closed: won't fix , I'm guessing the consensus is that the same email should not be sent twice.

  • 🇮🇹Italy afagioli Rome

    I agree the flow and user expectation is not completely clear.

    Where is the commerce invoice workflow described?

  • Pipeline finished with Skipped
    13 days ago
    #485747
    • jsacksick committed 878217f7 on 8.x-2.x
      Issue #3322909 by jsacksick, sadysierralta, attisan: Invoice email is...
  • 🇮🇱Israel jsacksick

    I went ahead and committed a slightly different patch.

  • 🇮🇹Italy afagioli Rome

    "Having different checkboxes wouldn't really help as it could be the email should still be sent on both transitions, and some invoices could be sent on confirm, others on paid?"

    Having 2 checkboxes would help when I have 3 differents projects:

    project A: owner needs to send a mail when a new order is confirmed
    project B: owner needs to send a mail when a new order is confirmed and later on once a payment is received
    project C: owner needs to send a mail when a order is paid.

    We need flexibility. Maybe even flexibility more that #8 cases.

Production build 0.71.5 2024