gpt4 book ai didi

php - 如何从 WooCommerce 中的新订单电子邮件中获取电子邮件收件人

转载 作者:行者123 更新时间:2023-12-04 01:40:32 26 4
gpt4 key购买 nike

我想从“新订单”电子邮件的 WooCommerce 电子邮件设置中获取收件人字段值,如下所示:

enter image description here

如何获取收件人字段?感谢您的帮助。

最佳答案

您可以使用以下简单的行来完成:

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'];

The Class WC_Email_New_Order is "An email sent to the admin when a new order is received / paid for" (as you can see on the docs).

The WC_Email method get_recipient() use in it's source code $this->recipient where $this is the WC_Email_New_Order Object in this case (as it extends the WC_Email Class).

You can use either the method get_recipient(), the property recipient or settings['recipient'].

关于php - 如何从 WooCommerce 中的新订单电子邮件中获取电子邮件收件人,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57612532/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com