I would like to get the recipients field value from WooCommerce emails settings for "New Order" email as shown below:

How to get Recipient(s) field? Any help is appreciated.
You can do it using the following simple line:
WC()->mailer()->get_emails()['WC_Email_New_Order']->recipient;
// Or: WC()->mailer()->get_emails()['WC_Email_New_Order']->get_recipient();
// Or: WC()->mailer()->get_emails()['WC_Email_New_Order']->settings['recipient'];
Or in details (code is commented):
// Get an instance of the WC_emails Object
$wc_emails = WC()->mailer();
// Get available emails notifications
$emails_array = $wc_emails->get_emails();
// Get the instance of the WC_Email_New_Order Object
$new_order_email = $emails_array['WC_Email_New_Order'];
// Get recipients from New Order email notification
$new_order_recipient = $new_order_email->recipient;
// Or $new_order_email->get_recipient();
// Or $new_order_email->settings['recipient'];
The Class
WC_Email_New_Orderis "An email sent to the admin when a new order is received / paid for" (as you can see on the docs).The
WC_Emailmethodget_recipient()use in it's source code$this->recipientwhere$thisis theWC_Email_New_OrderObject in this case (as it extends theWC_EmailClass).You can use either the method
get_recipient(), the propertyrecipientorsettings['recipient'].
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With