PHP Class WC_Emails

WooCommerce Emails Class which handles the sending on transactional emails and email templates. This class loads in available emails.
Author: WooThemes
Show file Open project: woocommerce/woocommerce Class Usage Examples

Public Properties

Property Type Description
$emails Array of email notification classes

Protected Properties

Property Type Description
$_instance The single instance of the class

Public Methods

Method Description
__clone ( ) Cloning is forbidden.
__construct ( ) Constructor for the email class hooks in all emails that can be sent.
__wakeup ( ) Unserializing instances of this class is forbidden.
backorder ( array $args ) Backorder notification email.
customer_detail_field_is_valid ( array $field ) : boolean Is customer detail field valid?
customer_details ( mixed $order, boolean $sent_to_admin = false, boolean $plain_text = false ) : string Add customer details to email templates.
customer_invoice ( $order ) Prepare and send the customer invoice email on demand.
customer_new_account ( integer $customer_id, array $new_customer_data = [], $password_generated = false ) Customer new account welcome email.
email_addresses ( $order, $sent_to_admin = false, $plain_text = false ) Get the email addresses.
email_footer ( ) Get the email footer.
email_header ( mixed $email_heading ) Get the email header.
get_emails ( ) : array 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 ( ) Init email classes.
init_transactional_emails ( ) Hook in all transactional emails.
instance ( ) : WC_Emails Main WC_Emails Instance.
low_stock ( WC_Product $product ) Low stock notification email.
no_stock ( WC_Product $product ) No stock notification email.
order_details ( $order, $sent_to_admin = false, $plain_text = false, $email = '' ) Show the order details table
order_meta ( mixed $order, boolean $sent_to_admin = false, boolean $plain_text = false ) : string Add order meta to email templates.
order_schema_markup ( mixed $order, boolean $sent_to_admin = false, boolean $plain_text = false ) Adds Schema.org markup for order in JSON-LD format.
send ( mixed $to, mixed $subject, mixed $message, string $headers = "Content-Type: text/html ", string $attachments = "" ) : boolean Send the email.
send_transactional_email ( ) Init the mailer instance and call the notifications for the current filter.
wrap_message ( mixed $email_heading, string $message, $plain_text = false ) : string Wraps a message in the woocommerce mail template.

Private Methods

Method Description
get_blogname ( ) : string Get blog name formatted for emails.

Method Details

__clone() public method

Cloning is forbidden.
Since: 2.1
public __clone ( )

__construct() public method

Constructor for the email class hooks in all emails that can be sent.
public __construct ( )

__wakeup() public method

Unserializing instances of this class is forbidden.
Since: 2.1
public __wakeup ( )

backorder() public method

Backorder notification email.
public backorder ( array $args )
$args array

customer_detail_field_is_valid() public method

Is customer detail field valid?
public customer_detail_field_is_valid ( array $field ) : boolean
$field array
return boolean

customer_details() public method

Add customer details to email templates.
public customer_details ( mixed $order, boolean $sent_to_admin = false, boolean $plain_text = false ) : string
$order mixed
$sent_to_admin boolean (default: false)
$plain_text boolean (default: false)
return string

customer_invoice() public method

Prepare and send the customer invoice email on demand.
public customer_invoice ( $order )

customer_new_account() public method

Customer new account welcome email.
public customer_new_account ( integer $customer_id, array $new_customer_data = [], $password_generated = false )
$customer_id integer
$new_customer_data array

email_addresses() public method

Get the email addresses.
public email_addresses ( $order, $sent_to_admin = false, $plain_text = false )

email_header() public method

Get the email header.
public email_header ( mixed $email_heading )
$email_heading mixed heading for the email

get_emails() public method

Return the email classes - used in admin to load settings.
public get_emails ( ) : array
return array

get_from_address() public method

Get from email address.
public get_from_address ( ) : string
return string

get_from_name() public method

Get from name for email.
public get_from_name ( ) : string
return string

init() public method

Init email classes.
public init ( )

init_transactional_emails() public static method

Hook in all transactional emails.
public static init_transactional_emails ( )

instance() public static method

Ensures only one instance of WC_Emails is loaded or can be loaded.
Since: 2.1
public static instance ( ) : WC_Emails
return WC_Emails Main instance

low_stock() public method

Low stock notification email.
public low_stock ( WC_Product $product )
$product WC_Product

no_stock() public method

No stock notification email.
public no_stock ( WC_Product $product )
$product WC_Product

order_details() public method

Show the order details table
public order_details ( $order, $sent_to_admin = false, $plain_text = false, $email = '' )

order_meta() public method

Add order meta to email templates.
public order_meta ( mixed $order, boolean $sent_to_admin = false, boolean $plain_text = false ) : string
$order mixed
$sent_to_admin boolean (default: false)
$plain_text boolean (default: false)
return string

order_schema_markup() public method

Adds Schema.org markup for order in JSON-LD format.
See also: WC_Structured_Data::generate_order_data()
Deprecation: 2.7.0
Since: 2.6.0
public order_schema_markup ( mixed $order, boolean $sent_to_admin = false, boolean $plain_text = false )
$order mixed
$sent_to_admin boolean (default: false)
$plain_text boolean (default: false)

send() public method

Send the email.
public send ( mixed $to, mixed $subject, mixed $message, string $headers = "Content-Type: text/html ", string $attachments = "" ) : boolean
$to mixed
$subject mixed
$message mixed
$headers string (default: "Content-Type: text/html\r\n")
$attachments string (default: "")
return boolean

send_transactional_email() public static method

Init the mailer instance and call the notifications for the current filter.
public static send_transactional_email ( )

wrap_message() public method

Wraps a message in the woocommerce mail template.
public wrap_message ( mixed $email_heading, string $message, $plain_text = false ) : string
$email_heading mixed
$message string
return string

Property Details

$_instance protected static property

The single instance of the class
protected static $_instance

$emails public property

Array of email notification classes
public $emails