WooCommerce Code Reference

WC_Emails

Emails class.

Table of Contents

$emails  : array<string|int, WC_Email>
Array of email notification classes
$_instance  : WC_Emails
The single instance of the class
$background_emailer  : WC_Background_Emailer
Background emailer class.
__clone()  : mixed
Cloning is forbidden.
__construct()  : mixed
Constructor for the email class hooks in all emails that can be sent.
__wakeup()  : mixed
Unserializing instances of this class is forbidden.
backorder()  : mixed
Backorder notification email.
customer_detail_field_is_valid()  : bool
Is customer detail field valid?
customer_details()  : mixed
Allows developers to add additional customer details to templates.
customer_invoice()  : mixed
Prepare and send the customer invoice email on demand.
customer_new_account()  : mixed
Customer new account welcome email.
email_addresses()  : mixed
Get the email addresses.
email_footer()  : mixed
Get the email footer.
email_footer_replace_site_title()  : string
Filter callback to replace {site_title} in email footer
email_header()  : mixed
Get the email header.
get_emails()  : array<string|int, WC_Email>
Return the email classes - used in admin to load settings.
get_from_address()  : string
Get from email address.
get_from_name()  : string
Get from name for email.
init()  : mixed
Init email classes.
init_transactional_emails()  : mixed
Hook in all transactional emails.
instance()  : WC_Emails
Main WC_Emails Instance.
low_stock()  : mixed
Low stock notification email.
no_stock()  : mixed
No stock notification email.
order_details()  : mixed
Show the order details table
order_downloads()  : mixed
Show order downloads in a table.
order_meta()  : mixed
Add order meta to email templates.
order_schema_markup()  : mixed
Adds Schema.org markup for order in JSON-LD format.
queue_transactional_email()  : mixed
Queues transactional email so it's not sent in current request if enabled, otherwise falls back to send now.
replace_placeholders()  : string
Replace placeholder text in strings.
send()  : bool
Send the email.
wrap_message()  : string
Wraps a message in the woocommerce mail template.
get_blogname()  : string
Get blog name formatted for emails.

Properties

Methods

__construct()

Constructor for the email class hooks in all emails that can be sent.

public __construct() : mixed
Return values
mixed

__wakeup()

Unserializing instances of this class is forbidden.

public __wakeup() : mixed
Tags
since
2.1
Return values
mixed

backorder()

Backorder notification email.

public backorder(array<string|int, mixed> $args) : mixed
Parameters
$args : array<string|int, mixed>

Arguments.

Return values
mixed

customer_detail_field_is_valid()

Is customer detail field valid?

public customer_detail_field_is_valid(array<string|int, mixed> $field) : bool
Parameters
$field : array<string|int, mixed>

Field data to check if is valid.

Return values
bool

customer_details()

Allows developers to add additional customer details to templates.

public customer_details(WC_Order $order[, bool $sent_to_admin = false ][, bool $plain_text = false ]) : mixed

In versions prior to 3.2 this was used for notes, phone and email but this data has moved.

Parameters
$order : WC_Order

Order instance.

$sent_to_admin : bool = false

If should sent to admin.

$plain_text : bool = false

If is plain text email.

Return values
mixed

customer_invoice()

Prepare and send the customer invoice email on demand.

public customer_invoice(int|WC_Order $order) : mixed
Parameters
$order : int|WC_Order

Order instance or ID.

Return values
mixed

customer_new_account()

Customer new account welcome email.

public customer_new_account(int $customer_id[, array<string|int, mixed> $new_customer_data = array() ][, bool $password_generated = false ]) : mixed
Parameters
$customer_id : int

Customer ID.

$new_customer_data : array<string|int, mixed> = array()

New customer data.

$password_generated : bool = false

If password is generated.

Return values
mixed

email_addresses()

Get the email addresses.

public email_addresses(WC_Order $order[, bool $sent_to_admin = false ][, bool $plain_text = false ]) : mixed
Parameters
$order : WC_Order

Order instance.

$sent_to_admin : bool = false

If should sent to admin.

$plain_text : bool = false

If is plain text email.

Return values
mixed

Filter callback to replace {site_title} in email footer

public email_footer_replace_site_title(string $string) : string
Parameters
$string : string

Email footer text.

Tags
since
3.3.0
deprecated
3.7.0
Return values
stringEmail footer text with any replacements done.

email_header()

Get the email header.

public email_header(mixed $email_heading) : mixed
Parameters
$email_heading : mixed

Heading for the email.

Return values
mixed

init_transactional_emails()

Hook in all transactional emails.

public static init_transactional_emails() : mixed
Return values
mixed

instance()

Main WC_Emails Instance.

public static instance() : WC_Emails

Ensures only one instance of WC_Emails is loaded or can be loaded.

Tags
since
2.1
static
Return values
WC_EmailsMain instance

order_details()

Show the order details table

public order_details(WC_Order $order[, bool $sent_to_admin = false ][, bool $plain_text = false ][, string $email = '' ]) : mixed
Parameters
$order : WC_Order

Order instance.

$sent_to_admin : bool = false

If should sent to admin.

$plain_text : bool = false

If is plain text email.

$email : string = ''

Email address.

Return values
mixed

order_downloads()

Show order downloads in a table.

public order_downloads(WC_Order $order[, bool $sent_to_admin = false ][, bool $plain_text = false ][, string $email = '' ]) : mixed
Parameters
$order : WC_Order

Order instance.

$sent_to_admin : bool = false

If should sent to admin.

$plain_text : bool = false

If is plain text email.

$email : string = ''

Email address.

Tags
since
3.2.0
Return values
mixed

order_meta()

Add order meta to email templates.

public order_meta(WC_Order $order[, bool $sent_to_admin = false ][, bool $plain_text = false ]) : mixed
Parameters
$order : WC_Order

Order instance.

$sent_to_admin : bool = false

If should sent to admin.

$plain_text : bool = false

If is plain text email.

Return values
mixed

order_schema_markup()

Adds Schema.org markup for order in JSON-LD format.

public order_schema_markup(WC_Order $order[, bool $sent_to_admin = false ][, bool $plain_text = false ]) : mixed
Parameters
$order : WC_Order

Order instance.

$sent_to_admin : bool = false

If should sent to admin.

$plain_text : bool = false

If is plain text email.

Tags
deprecated
3.0.0
see
WC_Structured_Data::generate_order_data()
since
2.6.0
Return values
mixed

queue_transactional_email()

Queues transactional email so it's not sent in current request if enabled, otherwise falls back to send now.

public static queue_transactional_email(mixed ...$args) : mixed
Parameters
$args : mixed

Optional arguments.

Return values
mixed

replace_placeholders()

Replace placeholder text in strings.

public replace_placeholders(string $string) : string
Parameters
$string : string

Email footer text.

Tags
since
3.7.0
Return values
stringEmail footer text with any replacements done.

send()

Send the email.

public send(mixed $to, mixed $subject, mixed $message[, string $headers = "Content-Type: text/html " ][, string $attachments = '' ]) : bool
Parameters
$to : mixed

Receiver.

$subject : mixed

Email subject.

$message : mixed

Message.

$headers : string = "Content-Type: text/html "

Email headers (default: "Content-Type: text/html\r\n").

$attachments : string = ''

Attachments (default: "").

Return values
bool

wrap_message()

Wraps a message in the woocommerce mail template.

public wrap_message(string $email_heading, string $message[, bool $plain_text = false ]) : string
Parameters
$email_heading : string

Heading text.

$message : string

Email message.

$plain_text : bool = false

Set true to send as plain text. Default to false.

Return values
string

get_blogname()

Get blog name formatted for emails.

private get_blogname() : string
Return values
string