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'];
或者详细说明(代码已经注释):
// 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'];
WC_Email_New_Order
类是一种当收到/支付新订单时会发送给管理员的电子邮件(正如您在文档中看到的)。WC_Email
方法get_recipient()
在其源代码中使用$this->recipient
,其中$this
在这种情况下是WC_Email_New_Order
对象(因为它扩展了WC_Email
类)。您可以使用get_recipient()
方法、属性recipient
或settings['recipient']
。
$new_order_email->settings['recipient'];
- LoicTheAztec