• Resolved fruostehaps

    (@fruostehaps)


    Hi I found this code in a previous tread, as I also need to set a custom email field to send a new order email notification to, but the code is not working. It tells me theres an error in the 4th last line: $emails .= ‘,’.$aditional_email;
    Can anyone tell me what is wrong?

    add_filter(‘woocommerce_email_recipient_new_order’, ‘additional_email_checkout’, 10, 2);
    function additional_email_checkout($emails, $object){
    $aditional_email = get_post_meta($object->id, ‘field_name‘, true);
    if($aditional_email){
    $emails .= ‘,’.$aditional_email;
    }
    return $emails;
    }

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author ThemeHigh

    (@themehigh)

    We believe that it might be an issue with the format of the single quotes. Could you please remove the single quotes and add them again to the code.

    We have checked and confirmed that the code is working fine.

    Or please try to copy the below code:

    add_filter('woocommerce_email_recipient_new_order', 'additional_email_checkout', 10, 2);
    function additional_email_checkout($emails, $object){
    $aditional_email = get_post_meta($object->id, 'your_field_name', true);
    if($aditional_email){
    $emails .= ','.$aditional_email;
    }
    return $emails;
    }

    Replace your_field_name with your additional email field name.

    Hope this will help.

    Thank you!

    Thread Starter fruostehaps

    (@fruostehaps)

    Hi.

    Now the code is working, thank you very much. I’ve also replaced the email field name to rep_email, but I do not receive a new order email to the mail inserted in the custom field in checkout. Is there anything else I need to do?

    Plugin Author ThemeHigh

    (@themehigh)

    We have checked in our testing environment and could see that the email is getting received to the secondary email address.

    Could you please raise a ticket through our website? We hope our technical team will be able to help you.

    Thank you!

    Plugin Author ThemeHigh

    (@themehigh)

    We hope your issue is resolved now.

    We are going to mark this thread as resolved.

    Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom email field code not working.’ is closed to new replies.