• Resolved Dexter0015

    (@improvedline)


    Hi,

    I’m developping a plugin for a client relative to woocommerce:

    To be short, it display a complexe form that allow customers to book a storage box in a specific location (several locations are available).

    In this context, since a box is located on a particular location site,
    I would like to be able to set the email expeditor (or at least the reply to address) depending on which site the box is located.

    This way, if the customer decide to reply to the email, it will automatically sent the reply to the corresponding location site address.

    **Here is a more “illustrated” way of explaining what I’m trying to do:**

    – “Box A” is located on “Site 1” (email: **site1**@domain.ext)
    – “Box B” is located on “Site 2” (email: **site2**@domain.ext)

    So if the customer book the “Box A”, the order confirmation email should be sent from : site1@domain.ext

    But if he book the “Box B”, it should be sent from : site2@domain.ext

    My issue is that I can’t find any hook that gives me access to the WC_Order object (or at least it’s id), the email is related to.

    I tried using the filter “woocommerce_email_headers” as it has 3 parameters :
    $headers : actuel headers of the email
    $email_id : the email identifier
    $object : the object the email is related to (could be product, customer, …)

    unfortunatelly it seems, from the [code reference][1], that it is never used for the 'customer_processing_order' email, so it looks like a dead end.

    Anyone has already try to achieve this (and maybe succeed) ?

    Ideally I would like to have something like this:

    `/**
    * Customize email expeditor (headers) for corresponding site expeditor
    * Function hooked to a filter/or action
    *
    * @param string $headers Current header
    * @param string $email_id email identifier
    * @param WC_Order $order Order
    *
    * @return string;
    */
    public function wc_customize_email_headers( $headers, $email_id, $order ) {

    if( $email_id == 'customer_processing_order' ) {
    // Do the magic using $order
    // and customize the headers if needed
    }

    return $headers;
    }`

    [1]: https://woocommerce.github.io/code-reference/files/woocommerce-includes-class-wc-emails.html#source-view.637

    • This topic was modified 1 year, 6 months ago by Dexter0015.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘customize email sender based on order meta data’ is closed to new replies.