Home Forums Plugins WooCommerce Email Template Customizer Bug report: customer_on_hold_order uses stale template and does not send correctly

Bug report: customer_on_hold_order uses stale template and does not send correctly

  • Author
    Posts
  • #257185

    Dia
    Participant

    Hello,

    we found a reproducible issue in WooCommerce Email Template Customizer on our site.

    When WooCommerce creates a bank-transfer order and changes it from pending to on-hold, WooCommerce correctly triggers the customer_on_hold_order email. However, your plugin appears to reuse stale renderer state from the previous email in the same request.

    What we found:
    – WooCommerce does trigger customer_on_hold_order normally.
    – Your plugin correctly selects the customer_on_hold_order template.
    – But during rendering, it uses the previous template instead, typically the admin new_order template.
    – As a result, the customer on-hold email is not sent/logged correctly for some orders.

    Technical detail:
    – In includes/email-trigger.php, the plugin calls Email_Render::init([ ‘template_id’ => $this->template_id ]).
    – In includes/email-render.php, Email_Render is implemented as a singleton.
    – Because the singleton is reused, template_id is only set on first construction and is not refreshed for the next email in the same request.
    – This causes the second email to render with the wrong template ID.

    Example from plugin logs:
    – For an affected order, the log shows customer_on_hold_order matched template 10137
    – But immediately after that, render logs show render – template_id : 9525
    – Template 9525 is the admin new_order template, not the customer on-hold template

    Impact:
    – On-hold bank-transfer customers may not receive the email with payment/bank details
    – Admin new-order email can still be sent, so the issue is easy to miss

    Could you please review this and confirm whether this is a known bug? It looks like the renderer state should be reset or the template_id should be updated for each email render within the same request.

    Best regards,
    Diana

You must be logged in to see replies to this topic. Click here to login or register