• Resolved kinsey95

    (@kinsey95)


    Hey, I’m using your plugin for adding a custom email field on the checkout page. Now I want to send a custom mail to that email which is added in the custom field.
    Can you please suggest to me the code snippet for the same? I’ve tried with the below code
    “$a = get_post_meta($order->id, ‘Email send for approval’, true);
    $to = $a; // [email protected]
    $subject = ‘The subject’;
    $body = ‘The email body content’;
    $headers = array(‘Content-Type: text/html; charset=UTF-8’);

    wp_mail( $to, $subject, $body, $headers );”

    But It is giving an error for the order id and it is not working as expected.

Viewing 1 replies (of 1 total)
  • Plugin Author ThemeHigh

    (@themehigh)

    Please try adding the below code in your active theme’s functions.php file.

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

    Replace your_field_name with your additional email field name.

    Thank you!

Viewing 1 replies (of 1 total)
  • The topic ‘Send email to custom email field’ is closed to new replies.