Support » Plugin: Checkout Field Editor (Checkout Manager) for WooCommerce » Use custom email field value to send CC new order mail

  • Resolved Argentum

    (@argentum)


    Hi,
    I beg your forgiveness if this is blatantly obvious and easy to accomplish.

    I want the customer to have the option of entering a chosen retailer’s email adress in a checkout custom email field, and use the value of that custom field (if not empty) as an extra address for a Woocommerce new order email.

    Is this possible with this plugin?

    Best regards
    Magnus

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

    (@themehigh)

    Unfortunately, this feature is not available in our plugin. However, you can achieve this requirement by adding the below hook in your theme’s functions.php.

    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;
    }

    Replace field_name with your field name.

    We hope this will help 🙂

    Thank you!

    Thread Starter Argentum

    (@argentum)

    Hi,
    Tried this, but the additional address isn’t added to the recipients. I created a new field with your plugin, the field name is billing_retailer_email. Am I doing it the right way?

    
    add_filter('woocommerce_email_recipient_new_order', 'additional_email_checkout', 10, 2);
    function additional_email_checkout($emails, $object){
    $additional_email = get_post_meta($object->id, 'billing_retailer_email', true);
    if($additional_email){
    $emails .= ','.$additional_email;
    }
    return $emails;
    }
    
    Thread Starter Argentum

    (@argentum)

    Sorry! My fault. I edited the wrong functions.php. Silly me. It worked like a charm! Much obliged!
    🙂
    Magnus

    Thread Starter Argentum

    (@argentum)

    Hm, can you enter more than one email address to a custom email address field? Could this field be used to spam? Would it be possible to add some kind of check so that just one email address is entered?

    • This reply was modified 1 year, 2 months ago by Argentum.
    Plugin Author ThemeHigh

    (@themehigh)

    If you only want to enter one email address in the field then you can provide the Email validation for that field.

    If you want to provide more than one email address then there is no direct option to validate this in our plugin. However, you can use the default WooCommerce hook available.

    You can achieve your requirement by adding custom PHP code to the below hook.

    do_action( 'woocommerce_after_checkout_validation', $data, $errors );

    Please note that this hook is used for adding additional validation.

    We hope this will help.

    Thank you!

    thanks!!! work!

    Plugin Author ThemeHigh

    (@themehigh)

    Great!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Use custom email field value to send CC new order mail’ is closed to new replies.