WooCommerce Code Reference

Search results

WC_Emails

Emails class.

Table of Contents

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

Properties

$emails

Array of email notification classes

public \WC_Email[] $emails = array()

Methods

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
static
Return values
WC_Emails

Main instance

__clone()

Cloning is forbidden.

public __clone( ) : mixed
Tags
since
Return values
mixed

__wakeup()

Unserializing instances of this class is forbidden.

public __wakeup( ) : mixed
Tags
since
Return values
mixed

init_transactional_emails()

Hook in all transactional emails.

public static init_transactional_emails( ) : mixed
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( ...$args : mixed ) : mixed
Parameters
$args : mixed

Optional arguments.

Return values
mixed

__construct()

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

public __construct( ) : mixed
Return values
mixed

init()

Init email classes.

public init( ) : mixed
Return values
mixed

get_emails()

Return the email classes - used in admin to load settings.

public get_emails( ) : \WC_Email[]
Return values
\WC_Email[]

get_from_name()

Get from name for email.

public get_from_name( ) : string
Return values
string

get_from_address()

Get from email address.

public get_from_address( ) : string
Return values
string

email_header()

Get the email header.

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

Heading for the email.

Return values
mixed

email_footer()

Get the email footer.

public email_footer( ) : mixed
Return values
mixed

replace_placeholders()

Replace placeholder text in strings.

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

Email footer text.

Tags
since
Return values
string

Email footer text with any replacements done.

email_footer_replace_site_title()

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
deprecated
Return values
string

Email footer text with any replacements done.

wrap_message()

Wraps a message in the woocommerce mail template.

public wrap_message( $email_heading : string , $message : string [, $plain_text : bool = 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

send()

Send the email.

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

Receiver.

$subject : mixed

Email subject.

$message : mixed

Message.

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

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

$attachments : string = ''

Attachments (default: "").

Return values
bool

customer_invoice()

Prepare and send the customer invoice email on demand.

public customer_invoice( $order : int|WC_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( $customer_id : int [, $new_customer_data : array = array() ] [, $password_generated : bool = false ] ) : mixed
Parameters
$customer_id : int

Customer ID.

$new_customer_data : array = array()

New customer data.

$password_generated : bool = false

If password is generated.

Return values
mixed

order_details()

Show the order details table

public order_details( $order : WC_Order [, $sent_to_admin : bool = false ] [, $plain_text : bool = false ] [, $email : string = '' ] ) : 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( $order : WC_Order [, $sent_to_admin : bool = false ] [, $plain_text : bool = false ] [, $email : string = '' ] ) : 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
Return values
mixed

order_meta()

Add order meta to email templates.

public order_meta( $order : WC_Order [, $sent_to_admin : bool = false ] [, $plain_text : bool = 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

customer_detail_field_is_valid()

Is customer detail field valid?

public customer_detail_field_is_valid( $field : array ) : bool
Parameters
$field : array

Field data to check if is valid.

Return values
bool

customer_details()

Allows developers to add additional customer details to templates.

public customer_details( $order : WC_Order [, $sent_to_admin : bool = false ] [, $plain_text : bool = 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

email_addresses()

Get the email addresses.

public email_addresses( $order : WC_Order [, $sent_to_admin : bool = false ] [, $plain_text : bool = 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

get_blogname()

Get blog name formatted for emails.

private get_blogname( ) : string
Return values
string

backorder()

Backorder notification email.

public backorder( $args : array ) : mixed
Parameters
$args : array

Arguments.

Return values
mixed

order_schema_markup()

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

public order_schema_markup( $order : WC_Order [, $sent_to_admin : bool = false ] [, $plain_text : bool = 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
see
since
Return values
mixed
Back to the top