WooCommerce Code Reference

WC_Email_Customer_Abandoned_Cart_Recovery extends WC_Email

Customer Abandoned Cart Recovery email.

A transactional email that prompts the customer to complete a checkout they left pending. The send is scheduled via Action Scheduler two hours after the pending order is created, gated on the merchant's automated setting. Merchants can also trigger the email manually from the order edit page.

Tags
class

WC_Email_Customer_Abandoned_Cart_Recovery

version
11.0.0

Table of Contents

ABANDONMENT_THRESHOLD_SECONDS  = HOUR_IN_SECONDS
Minimum age (in seconds, from `date_created`) before an order is considered actually abandoned. Gives the customer a window to come back and complete the checkout on their own before merchants can nudge them.
AUTO_SEND_DELAY_SECONDS  = 2 * HOUR_IN_SECONDS
Delay between order creation and the automated recovery send.
EMAIL_ID  = 'customer_abandoned_cart_recovery'
Email identifier — kept in `$this->id` for the rest of WC_Email's machinery but also exposed as a constant so static methods (and external callers using the unsubscribe storage) can reference the same string without it drifting out of sync with the constructor.
KNOWN_RECOVERY_HANDLERS  = array('automatewoo/automatewoo.php' => 'AutomateWoo', 'mailpoet/mailpoet.php' => 'MailPoet')
Plugins known to provide their own abandoned cart recovery flow.
MANUAL_RECOVERY_EMAIL_SEND_ACTION  = AutomatticWooCommerceInternalAbandonedCartRecoveryManualSendHandler::MANUAL_SEND_ACTION
Order action id used by the recovery email send item on the order edit page.
META_KEY_SENT_AT  = '_abandoned_cart_recovery_email_sent_at'
Order meta key recording the timestamp of the most recent send.
SKIP_REASON_NO_RECIPIENT  = 'no_recipient'
Skip-reason identifier used when the email has no recipient address.
ABANDONED_STATUSES  = array(AutomatticWooCommerceEnumsOrderStatus::PENDING, AutomatticWooCommerceEnumsOrderStatus::CHECKOUT_DRAFT)
Order statuses that represent an abandoned checkout for the purposes of the manual-send action and the trigger-level status gate.
$bcc  : string
Bcc recipients for the email.
$block_email_editor_enabled  : bool
Whether email block editor feature is enabled.
$cc  : string
Cc recipients for the email.
$description  : string
Description for the email.
$email_group  : string
Email group slug.
$email_improvements_enabled  : bool
Whether email improvements feature is enabled.
$email_type  : string
E-mail type: plain, html or multipart.
$enabled  : string
'yes' if the method is enabled.
$errors  : array<string|int, mixed>
Validation errors.
$find  : array<string|int, mixed>
Strings to find in subjects/headings.
$form_fields  : array<string|int, mixed>
Form option fields.
$heading  : string
Default heading.
$id  : string
ID of the class extending the settings API. Used in option names.
$mime_boundary  : string
Mime boundary (for multipart emails).
$mime_boundary_header  : string
Mime boundary header (for multipart emails).
$object  : object|bool
Object this email is for, for example a customer, product, or email.
$personalizer  : TransactionalEmailPersonalizer
Personalizer instance for converting Personalization tags.
$placeholders  : array<string|int, mixed>
Strings to find/replace in subjects/headings.
$plain_replace  : mixed
List of pattern replacements corresponding to patterns searched.
$plain_search  : array<string|int, mixed>
List of preg* regular expression patterns to search for, used in conjunction with $plain_replace.
$plugin_id  : string
The plugin ID. Used for option names.
$recipient  : string
Recipients for the email.
$replace  : array<string|int, mixed>
Strings to replace in subjects/headings.
$sending  : bool
True when email is being sent.
$settings  : array<string|int, mixed>
Setting values.
$subject  : string
Default subject.
$template_base  : string
Template path.
$template_block  : string
Initial email block template path.
$template_block_content  : string
Block content template path.
$template_html  : string
HTML template path.
$template_plain  : string
Plain text template path.
$title  : string
Email method title.
$customer_email  : bool
True when the email notification is sent to customers.
$data  : array<string|int, mixed>
The posted settings data. When empty, $_POST data will be used.
$manual  : bool
True when the email notification is sent manually only.
__construct()  : mixed
Constructor.
add_error()  : mixed
Add an error message for display in admin on save.
admin_options()  : mixed
Output the admin options table.
display_errors()  : mixed
Display admin error messages.
format_settings()  : array<string|int, mixed>
Format settings if needed.
format_string()  : string
Format email string.
generate_checkbox_html()  : string
Generate Checkbox HTML.
generate_color_html()  : string
Generate Color Picker Input HTML.
generate_decimal_html()  : string
Generate Decimal Input HTML.
generate_multiselect_html()  : string
Generate Multiselect HTML.
generate_password_html()  : string
Generate Password Input HTML.
generate_price_html()  : string
Generate Price Input HTML.
generate_safe_text_html()  : string
Generates HTML for the 'safe_text' input type (mostly used for gateway-related settings).
generate_select_html()  : string
Generate Select HTML.
generate_settings_html()  : string
Generate Settings HTML.
generate_text_html()  : string
Generate Text Input HTML.
generate_textarea_html()  : string
Generate Textarea HTML.
generate_title_html()  : string
Generate Title HTML.
get_active_recovery_handlers()  : array<string, string>
Currently-active known recovery handlers, keyed by plugin file path with the display name as value.
get_additional_content()  : string
Return content from the additional_content field.
get_attachments()  : array<string|int, mixed>
Get email attachments.
get_bcc_recipient()  : string
Get valid Bcc recipients.
get_block_editor_email_template_content()  : string
Get block editor email template content.
get_blogname()  : string
Get WordPress blog name.
get_cc_recipient()  : string
Get valid Cc recipients.
get_content()  : string
Get email content.
get_content_html()  : string
Get content html.
get_content_plain()  : string
Get content plain.
get_content_type()  : string
Get email content type.
get_custom_attribute_html()  : string
Get custom attributes.
get_default_additional_content()  : string
Default content to show below main email content.
get_default_heading()  : string
Get default email heading.
get_default_subject()  : string
Get default email subject.
get_description()  : string
Return the email's description
get_description_html()  : string
Get HTML for descriptions.
get_email_group_title()  : string
Get the title for the current email group.
get_email_groups()  : array<string|int, mixed>
Get available email groups with their titles.
get_email_type()  : string
Return email type.
get_email_type_options()  : array<string|int, mixed>
Email type options.
get_errors()  : mixed
Get admin error messages.
get_field_default()  : string
Get a fields default value. Defaults to "" if not set.
get_field_key()  : string
Prefix key for settings.
get_field_type()  : string
Get a fields type. Defaults to "text" if not set.
get_field_value()  : string
Get a field's posted and validated value.
get_form_fields()  : array<string|int, mixed>
Get the form fields after they are initialized.
get_from_address()  : string
Get the from address for outgoing emails.
get_from_name()  : string
Get the from name for outgoing emails.
get_headers()  : string
Get email headers.
get_heading()  : string
Get email heading.
get_option()  : string
Get option from DB.
get_option_key()  : string
Return the name of the option in the WP DB.
get_post_data()  : array<string|int, mixed>
Returns the POSTed data, to be used to save the settings.
get_preheader()  : string
Get email preheader.
get_recipient()  : string
Get valid recipients.
get_recovery_url()  : string
Get the URL the recovery email should send the customer to.
get_reply_to_address()  : string
Get the reply-to address for outgoing emails.
get_reply_to_enabled()  : bool
Check if reply-to is enabled for outgoing emails.
get_reply_to_name()  : string
Get the reply-to name for outgoing emails.
get_subject()  : string
Get email subject.
get_template()  : string
Get template.
get_theme_template_file()  : string
Get the template file in the current theme.
get_title()  : string
Return the email's title
get_tooltip_html()  : string
Get HTML for tooltips.
get_unsubscribe_url()  : string
Get the unsubscribe URL for the currently-bound order's recipient.
handle_multipart()  : PHPMailer
Handle multipart mail.
handle_recovery_email_send()  : void
Handle a merchant-initiated send from the order edit page.
init_form_fields()  : void
Initialise settings form fields.
init_settings()  : mixed
Initialise Settings.
is_automated()  : bool
Whether the merchant has opted into automated scheduling.
is_customer_email()  : bool
Checks if this email is customer focussed.
is_enabled()  : bool
Checks if this email is enabled and will be sent.
is_manual()  : bool
Checks if this email is manually sent
is_recipient_unsubscribed()  : bool
Whether the given email has opted out of checkout recovery emails.
is_suppressed()  : bool
Whether the recovery email should be skipped.
prevent_lazy_loading_on_attachment()  : array<string|int, mixed>
Prevent lazy loading on attachment images in email context by adding skip classes.
process_admin_options()  : bool
Processes and saves options.
register_order_action()  : array<string|int, mixed>
Add the manual-send item to the order actions dropdown.
restore_locale()  : mixed
Restore the locale to the default locale. Use after finished with setup_locale.
send()  : bool
Send an email.
set_object()  : void
Set the object for the outgoing email.
set_post_data()  : mixed
Sets the POSTed data. This method can be used to set specific data, instead of taking it from the $_POST array.
setup_locale()  : mixed
Set the locale to the store locale for customer emails to make sure emails are in the store language.
style_inline()  : string
Apply inline styles to dynamic content.
trigger()  : bool
Trigger the sending of this email.
update_option()  : bool
Update a single option.
validate_checkbox_field()  : string
Validate Checkbox Field.
validate_decimal_field()  : string
Validate Decimal Field.
validate_multiselect_field()  : string|array<string|int, mixed>
Validate Multiselect Field.
validate_password_field()  : string
Validate Password Field. No input sanitization is used to avoid corrupting passwords.
validate_price_field()  : string
Validate Price Field.
validate_safe_text_field()  : string
Sanitize 'Safe Text' fields.
validate_select_field()  : string
Validate Select Field.
validate_settings_fields()  : mixed
Validate the data on the "Settings" form.
validate_text_field()  : string
Validate Text Field.
validate_textarea_field()  : string
Validate Textarea Field.
admin_actions()  : mixed
Admin actions.
delete_template_action()  : mixed
Delete template action.
get_bcc_field()  : array<string|int, mixed>
Get the bcc field definition.
get_cc_field()  : array<string|int, mixed>
Get the cc field definition.
get_must_use_css_styles()  : string
Returns CSS styles that should be included with all HTML e-mails, regardless of theme specific customizations.
get_option_or_transient()  : mixed
Get an option or transient for email preview.
get_preheader_field()  : array<string|int, mixed>
Get the preheader field definition.
is_order_eligible_for_recovery()  : bool
Whether an order is in a state that warrants a recovery email.
move_template_action()  : mixed
Move template action.
save_template()  : mixed
Save the email templates.
send_if_recipient()  : bool
Send the email when a recipient is available, regardless of the enabled setting.
send_notification()  : bool
Send the email notification when enabled and a recipient is available.
set_defaults()  : array<string|int, mixed>
Set default required properties for each field.
supports_emogrifier()  : bool
Return if emogrifier library is supported.
apply_inline_style()  : string
Apply inline styles to dynamic content using Emogrifier library (if supported).
clear_alt_body_field()  : void
Clears the PhpMailer AltBody field, to prevent that content from leaking across emails.
get_block_email_html_content()  : string|null
Gerenerates the HTML content for the email from a block based email.

Constants

ABANDONMENT_THRESHOLD_SECONDS

Minimum age (in seconds, from `date_created`) before an order is considered actually abandoned. Gives the customer a window to come back and complete the checkout on their own before merchants can nudge them.

public mixed ABANDONMENT_THRESHOLD_SECONDS = HOUR_IN_SECONDS

AUTO_SEND_DELAY_SECONDS

Delay between order creation and the automated recovery send.

public mixed AUTO_SEND_DELAY_SECONDS = 2 * HOUR_IN_SECONDS

Deliberately longer than ABANDONMENT_THRESHOLD_SECONDS so the auto-send never races the customer's own checkout retry. The shorter eligibility threshold still gates manual sends from the order edit page so merchants have an earlier window to intervene.

Tags
since
11.0.0

EMAIL_ID

Email identifier — kept in `$this->id` for the rest of WC_Email's machinery but also exposed as a constant so static methods (and external callers using the unsubscribe storage) can reference the same string without it drifting out of sync with the constructor.

public mixed EMAIL_ID = 'customer_abandoned_cart_recovery'

MANUAL_RECOVERY_EMAIL_SEND_ACTION

Order action id used by the recovery email send item on the order edit page.

public mixed MANUAL_RECOVERY_EMAIL_SEND_ACTION = AutomatticWooCommerceInternalAbandonedCartRecoveryManualSendHandler::MANUAL_SEND_ACTION

Re-exports ManualSendHandler::MANUAL_SEND_ACTION so external callers (and tests) can reference it from the email class. Source of truth lives on the dispatcher because its hook registration runs before this email class file is included.

META_KEY_SENT_AT

Order meta key recording the timestamp of the most recent send.

public mixed META_KEY_SENT_AT = '_abandoned_cart_recovery_email_sent_at'

Written by trigger() after a successful dispatch (manual or automated) of the abandoned cart recovery email.

SKIP_REASON_NO_RECIPIENT

Skip-reason identifier used when the email has no recipient address.

public mixed SKIP_REASON_NO_RECIPIENT = 'no_recipient'
Tags
since
10.9.0

ABANDONED_STATUSES

Order statuses that represent an abandoned checkout for the purposes of the manual-send action and the trigger-level status gate.

private array<string|int, string> ABANDONED_STATUSES = array(AutomatticWooCommerceEnumsOrderStatus::PENDING, AutomatticWooCommerceEnumsOrderStatus::CHECKOUT_DRAFT)
  • pending — classic checkout reached "place order" but no payment yet.
  • checkout-draft — block checkout (Store API) parks the order here while the customer is mid-flow. May have no billing email yet, in which case trigger() no-ops.

Covers block checkout as well as classic. The automated scheduler is scoped to pending.

Tags
see
Scheduler::get_eligible_statuses()

Properties

$find

Strings to find in subjects/headings.

public array<string|int, mixed> $find = array()
Tags
deprecated
3.2.0

in favour of placeholders

$heading

Default heading.

public string $heading = ''

Supported for backwards compatibility but we recommend overloading the get_default_x methods instead so localization can be done when needed.

$plain_replace

List of pattern replacements corresponding to patterns searched.

public mixed $plain_replace = array( '', // Non-legal carriage return. ' ', // Non-breaking space. '"', // Double quotes. "'", // Single quotes. '>', // Greater-than. '<', // Less-than. '&', // Ampersand. '&', // Ampersand. '(c)', // Copyright. '(tm)', // Trademark. '(R)', // Registered. '--', // mdash. '-', // ndash. '*', // Bullet. '£', // Pound sign. 'EUR', // Euro sign. € ?. '$', // Dollar sign. '', // Unknown/unhandled entities. ' ', )

@var array $plain_replace

Tags
see

$plain_search

List of preg* regular expression patterns to search for, used in conjunction with $plain_replace.

public array<string|int, mixed> $plain_search = array( "/ /", // Non-legal carriage return. '/&(nbsp|#0*160);/i', // Non-breaking space. '/&(quot|rdquo|ldquo|#0*8220|#0*8221|#0*147|#0*148);/i', // Double quotes. '/&(apos|rsquo|lsquo|#0*8216|#0*8217);/i', // Single quotes. '/&gt;/i', // Greater-than. '/&lt;/i', // Less-than. '/&#0*38;/i', // Ampersand. '/&amp;/i', // Ampersand. '/&(copy|#0*169);/i', // Copyright. '/&(trade|#0*8482|#0*153);/i', // Trademark. '/&(reg|#0*174);/i', // Registered. '/&(mdash|#0*151|#0*8212);/i', // mdash. '/&(ndash|minus|#0*8211|#0*8722);/i', // ndash. '/&(bull|#0*149|#0*8226);/i', // Bullet. '/&(pound|#0*163);/i', // Pound sign. '/&(euro|#0*8364);/i', // Euro sign. '/&(dollar|#0*36);/i', // Dollar sign. '/&[^&\s;]+;/i', // Unknown/unhandled entities. '/[ ]{2,}/', )

https://raw.github.com/ushahidi/wp-silcc/master/class.html2text.inc

$replace

Strings to replace in subjects/headings.

public array<string|int, mixed> $replace = array()
Tags
deprecated
3.2.0

in favour of placeholders

$subject

Default subject.

public string $subject = ''

Supported for backwards compatibility but we recommend overloading the get_default_x methods instead so localization can be done when needed.

$template_block_content

Block content template path.

public string $template_block_content = 'emails/block/general-block-email.php'

Methods

format_settings()

Format settings if needed.

public format_settings(array<string|int, mixed> $value) : array<string|int, mixed>
Parameters
$value : array<string|int, mixed>

Value to format.

Tags
deprecated
2.6.0

Unused.

Return values
array<string|int, mixed>

format_string()

Format email string.

public format_string(mixed $string) : string
Parameters
$string : mixed

Text to replace placeholders in.

Return values
string

generate_checkbox_html()

Generate Checkbox HTML.

public generate_checkbox_html(string $key, array<string|int, mixed> $data) : string
Parameters
$key : string

Field key.

$data : array<string|int, mixed>

Field data.

Tags
since
1.0.0
Return values
string

generate_color_html()

Generate Color Picker Input HTML.

public generate_color_html(string $key, array<string|int, mixed> $data) : string
Parameters
$key : string

Field key.

$data : array<string|int, mixed>

Field data.

Tags
since
1.0.0
Return values
string

generate_decimal_html()

Generate Decimal Input HTML.

public generate_decimal_html(string $key, array<string|int, mixed> $data) : string
Parameters
$key : string

Field key.

$data : array<string|int, mixed>

Field data.

Tags
since
1.0.0
Return values
string

generate_multiselect_html()

Generate Multiselect HTML.

public generate_multiselect_html(string $key, array<string|int, mixed> $data) : string
Parameters
$key : string

Field key.

$data : array<string|int, mixed>

Field data.

Tags
since
1.0.0
Return values
string

generate_password_html()

Generate Password Input HTML.

public generate_password_html(string $key, array<string|int, mixed> $data) : string
Parameters
$key : string

Field key.

$data : array<string|int, mixed>

Field data.

Tags
since
1.0.0
Return values
string

generate_price_html()

Generate Price Input HTML.

public generate_price_html(string $key, array<string|int, mixed> $data) : string
Parameters
$key : string

Field key.

$data : array<string|int, mixed>

Field data.

Tags
since
1.0.0
Return values
string

generate_safe_text_html()

Generates HTML for the 'safe_text' input type (mostly used for gateway-related settings).

public generate_safe_text_html(string $key, array<string|int, mixed> $data) : string
Parameters
$key : string

Field key.

$data : array<string|int, mixed>

Field data.

Tags
since
7.6.0
Return values
string

generate_select_html()

Generate Select HTML.

public generate_select_html(string $key, array<string|int, mixed> $data) : string
Parameters
$key : string

Field key.

$data : array<string|int, mixed>

Field data.

Tags
since
1.0.0
Return values
string

generate_settings_html()

Generate Settings HTML.

public generate_settings_html([array<string|int, mixed> $form_fields = array() ][, bool $echo = true ]) : string

Generate the HTML for the fields on the "settings" screen.

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

(default: array()) Array of form fields.

$echo : bool = true

Echo or return.

Tags
since
1.0.0
uses
method_exists()
Return values
stringthe html for the settings

generate_text_html()

Generate Text Input HTML.

public generate_text_html(string $key, array<string|int, mixed> $data) : string
Parameters
$key : string

Field key.

$data : array<string|int, mixed>

Field data.

Tags
since
1.0.0
Return values
string

generate_textarea_html()

Generate Textarea HTML.

public generate_textarea_html(string $key, array<string|int, mixed> $data) : string
Parameters
$key : string

Field key.

$data : array<string|int, mixed>

Field data.

Tags
since
1.0.0
Return values
string

generate_title_html()

Generate Title HTML.

public generate_title_html(string $key, array<string|int, mixed> $data) : string
Parameters
$key : string

Field key.

$data : array<string|int, mixed>

Field data.

Tags
since
1.0.0
Return values
string

get_active_recovery_handlers()

Currently-active known recovery handlers, keyed by plugin file path with the display name as value.

public static get_active_recovery_handlers() : array<string, string>
Tags
since
11.0.0
Return values
array<string, string>Map of plugin file path → display name for plugins that are active.

get_additional_content()

Return content from the additional_content field.

public get_additional_content() : string

Displayed above the footer.

Tags
since
3.7.0
Return values
string

get_attachments()

Get email attachments.

public get_attachments() : array<string|int, mixed>
Return values
array<string|int, mixed>

get_block_editor_email_template_content()

Get block editor email template content.

public get_block_editor_email_template_content() : string
Return values
string

get_content_type()

Get email content type.

public get_content_type([string $default_content_type = '' ]) : string
Parameters
$default_content_type : string = ''

Default wp_mail() content type.

Return values
string

get_custom_attribute_html()

Get custom attributes.

public get_custom_attribute_html(array<string|int, mixed> $data) : string
Parameters
$data : array<string|int, mixed>

Field data.

Return values
string

get_description_html()

Get HTML for descriptions.

public get_description_html(array<string|int, mixed> $data) : string
Parameters
$data : array<string|int, mixed>

Data for the description.

Return values
string

get_email_group_title()

Get the title for the current email group.

public get_email_group_title() : string
Tags
since
10.3.0
Return values
stringThe email group title. Falls back to the email group slug if not found.

get_email_groups()

Get available email groups with their titles.

public get_email_groups() : array<string|int, mixed>
Tags
since
10.3.0
Return values
array<string|int, mixed>Associative array of email group slugs => titles.

get_email_type_options()

Email type options.

public get_email_type_options() : array<string|int, mixed>
Return values
array<string|int, mixed>

get_field_default()

Get a fields default value. Defaults to "" if not set.

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

Field array.

Return values
string

get_field_type()

Get a fields type. Defaults to "text" if not set.

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

Field array.

Return values
string

get_field_value()

Get a field's posted and validated value.

public get_field_value(string $key, array<string|int, mixed> $field[, array<string|int, mixed> $post_data = array() ]) : string
Parameters
$key : string

Field key.

$field : array<string|int, mixed>

Field array.

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

Posted data.

Return values
string

get_from_address()

Get the from address for outgoing emails.

public get_from_address([string $from_email = '' ]) : string
Parameters
$from_email : string = ''

Default wp_mail() email address to send from.

Return values
string

get_from_name()

Get the from name for outgoing emails.

public get_from_name([string $from_name = '' ]) : string
Parameters
$from_name : string = ''

Default wp_mail() name associated with the "from" email address.

Return values
string

get_option()

Get option from DB.

public get_option(string $key[, mixed $empty_value = null ]) : string

Gets an option from the settings API, using defaults if necessary to prevent undefined notices.

Parameters
$key : string

Option key.

$empty_value : mixed = null

Value when empty.

Return values
stringThe value specified for the option or a default value for the option.

get_recovery_url()

Get the URL the recovery email should send the customer to.

public get_recovery_url() : string

Returns the order's pay endpoint, which resumes the checkout for the pending order. A future iteration may swap this for a single-use signed URL with explicit expiry (see woocommerce_abandoned_cart_recovery_url filter).

Tags
since
11.0.0
Return values
string

get_reply_to_address()

Get the reply-to address for outgoing emails.

public get_reply_to_address([string $reply_to_email = '' ]) : string
Parameters
$reply_to_email : string = ''

Default reply-to email address.

Return values
string

get_reply_to_enabled()

Check if reply-to is enabled for outgoing emails.

public get_reply_to_enabled() : bool
Return values
bool

get_reply_to_name()

Get the reply-to name for outgoing emails.

public get_reply_to_name([string $reply_to_name = '' ]) : string
Parameters
$reply_to_name : string = ''

Default reply-to name.

Return values
string

get_template()

Get template.

public get_template(string $type) : string
Parameters
$type : string

Template type. Can be either 'template_html', 'template_plain' or 'template_block'.

Return values
string

get_theme_template_file()

Get the template file in the current theme.

public get_theme_template_file(string $template) : string
Parameters
$template : string

Template name.

Return values
string

get_tooltip_html()

Get HTML for tooltips.

public get_tooltip_html(array<string|int, mixed> $data) : string
Parameters
$data : array<string|int, mixed>

Data for the tooltip.

Return values
string

get_unsubscribe_url()

Get the unsubscribe URL for the currently-bound order's recipient.

public get_unsubscribe_url() : string

Returns an HMAC-signed URL routed through Endpoint::QUERY_VAR (?wc-email-unsubscribe=…) and handled by UnsubscribesEndpoint. Empty when no order is bound or the order has no billing email — both states mean there's no recipient to unsubscribe and the template should suppress the footer link.

Tags
since
11.0.0
Return values
string

handle_multipart()

Handle multipart mail.

public handle_multipart(PHPMailer $mailer) : PHPMailer
Parameters
$mailer : PHPMailer

PHPMailer object.

Return values
PHPMailer

handle_recovery_email_send()

Handle a merchant-initiated send from the order edit page.

public handle_recovery_email_send(WC_Order $order) : void

Fired by woocommerce_order_action_send_abandoned_cart_recovery_email after the order metabox save flow has validated the request. We re-check the capability and order status as defense in depth in case the hook is invoked from a non-metabox path.

Parameters
$order : WC_Order

The order whose customer should receive the email.

Tags
since
11.0.0
Return values
void

init_settings()

Initialise Settings.

public init_settings() : mixed

Store all settings in a single database entry and make sure the $settings array is either the default or the settings stored in the database.

Tags
since
1.0.0
uses

get_option(), add_option()

Return values
mixed

is_automated()

Whether the merchant has opted into automated scheduling.

public is_automated() : bool

When false, the email is only dispatched via the manual-send action on the order edit page. The Action Scheduler integration consults this before scheduling a send.

Tags
since
11.0.0
Return values
bool

is_recipient_unsubscribed()

Whether the given email has opted out of checkout recovery emails.

public static is_recipient_unsubscribed(string $email) : bool

Static so the gate can be reused from the trigger-side check, the dropdown gate, and any future auto-send scheduler — without each caller needing to thread the repository through.

Parameters
$email : string

Raw recipient email.

Tags
since
11.0.0
Return values
bool

is_suppressed()

Whether the recovery email should be skipped.

public static is_suppressed() : bool

The merchant's own opt-out lives on the enabled toggle in Settings → Emails, which trigger() checks via is_enabled(). This method is the additional gate partner plugins (AutomateWoo, MailPoet, etc.) can hook into to short-circuit the send without touching the merchant's saved settings. Static so the manual-send handler and the scheduler can call it without instantiating the email class.

Tags
since
11.0.0
Return values
bool

prevent_lazy_loading_on_attachment()

Prevent lazy loading on attachment images in email context by adding skip classes.

public prevent_lazy_loading_on_attachment(array<string|int, mixed> $attributes) : array<string|int, mixed>

This is hooked into the wp_get_attachment_image_attributes filter.

Parameters
$attributes : array<string|int, mixed>

The image attributes array.

Return values
array<string|int, mixed>The modified image attributes array.

process_admin_options()

Processes and saves options.

public process_admin_options() : bool

If there is an error thrown, will continue to save and validate fields, but will leave the erroring field out.

Return values
boolwas anything saved?

register_order_action()

Add the manual-send item to the order actions dropdown.

public register_order_action(array<string|int, mixed> $actions, WC_Order|null $order) : array<string|int, mixed>

Surfaced for the statuses listed in ABANDONED_STATUSES (pending + checkout-draft) so merchants can't accidentally email a "pick up where you left off" prompt to a customer whose order has already moved past abandonment. A capability check guards against role configurations that grant the order edit page to users without edit_shop_orders.

Parameters
$actions : array<string|int, mixed>

Existing order actions keyed by action id.

$order : WC_Order|null

Order being rendered, or null in contexts without one.

Tags
since
11.0.0
Return values
array<string|int, mixed>

restore_locale()

Restore the locale to the default locale. Use after finished with setup_locale.

public restore_locale() : mixed
Return values
mixed

send()

Send an email.

public send(string $to, string $subject, string $message, string $headers, array<string|int, mixed> $attachments) : bool
Parameters
$to : string

Email to.

$subject : string

Email subject.

$message : string

Email message.

$headers : string

Email headers.

$attachments : array<string|int, mixed>

Email attachments.

Return values
boolsuccess

set_object()

Set the object for the outgoing email.

public set_object(object $object) : void
Parameters
$object : object

Object this email is for, e.g. customer, or product.

Return values
void

set_post_data()

Sets the POSTed data. This method can be used to set specific data, instead of taking it from the $_POST array.

public set_post_data([array<string|int, mixed> $data = array() ]) : mixed
Parameters
$data : array<string|int, mixed> = array()

Posted data.

Return values
mixed

setup_locale()

Set the locale to the store locale for customer emails to make sure emails are in the store language.

public setup_locale() : mixed
Return values
mixed

style_inline()

Apply inline styles to dynamic content.

public style_inline(string|null $content) : string

We only inline CSS for html emails.

Parameters
$content : string|null

Content that will receive inline styles.

Tags
version
10.2.0
Return values
string

trigger()

Trigger the sending of this email.

public trigger(int $order_id) : bool

Called by Scheduler::handle_scheduled_send() after Action Scheduler dispatches woocommerce_send_abandoned_cart_recovery_notification, and directly by the manual-send action on the order edit page.

Parameters
$order_id : int

The order ID.

Tags
since
11.0.0
Return values
boolTrue when an email was dispatched in this call, false when any gate (suppression, disabled, ineligible, unsubscribed, dedup) or the underlying `send()` rejected the request.

update_option()

Update a single option.

public update_option(string $key[, mixed $value = '' ]) : bool
Parameters
$key : string

Option key.

$value : mixed = ''

Value to set.

Tags
since
3.4.0
Return values
boolwas anything saved?

validate_checkbox_field()

Validate Checkbox Field.

public validate_checkbox_field(string $key, string $value) : string

If not set, return "no", otherwise return "yes".

Parameters
$key : string

Field key.

$value : string

Posted Value.

Return values
string

validate_decimal_field()

Validate Decimal Field.

public validate_decimal_field(string $key, string $value) : string

Make sure the data is escaped correctly, etc.

Parameters
$key : string

Field key.

$value : string

Posted Value.

Return values
string

validate_multiselect_field()

Validate Multiselect Field.

public validate_multiselect_field(string $key, string $value) : string|array<string|int, mixed>
Parameters
$key : string

Field key.

$value : string

Posted Value.

Return values
string|array<string|int, mixed>

validate_password_field()

Validate Password Field. No input sanitization is used to avoid corrupting passwords.

public validate_password_field(string $key, string $value) : string
Parameters
$key : string

Field key.

$value : string

Posted Value.

Return values
string

validate_price_field()

Validate Price Field.

public validate_price_field(string $key, string $value) : string

Make sure the data is escaped correctly, etc.

Parameters
$key : string

Field key.

$value : string

Posted Value.

Return values
string

validate_safe_text_field()

Sanitize 'Safe Text' fields.

public validate_safe_text_field(string $key, string $value) : string

These fields are similar to regular text fields, but a much smaller set of HTML tags are allowed. By default, this means <br>, <img>, <p> and <span> tags.

Note: this is a sanitization method, rather than a validation method (the name is due to some historic naming choices).

Parameters
$key : string

Field key (currently unused).

$value : string

Posted Value.

Return values
string

validate_select_field()

Validate Select Field.

public validate_select_field(string $key, string $value) : string
Parameters
$key : string

Field key.

$value : string

Posted Value.

Return values
string

validate_settings_fields()

Validate the data on the "Settings" form.

public validate_settings_fields([array<string|int, mixed> $form_fields = array() ]) : mixed
Parameters
$form_fields : array<string|int, mixed> = array()

Array of fields.

Tags
deprecated
2.6.0

No longer used.

Return values
mixed

validate_text_field()

Validate Text Field.

public validate_text_field(string $key, string $value) : string

Make sure the data is escaped correctly, etc.

Parameters
$key : string

Field key.

$value : string

Posted Value.

Return values
string

validate_textarea_field()

Validate Textarea Field.

public validate_textarea_field(string $key, string $value) : string
Parameters
$key : string

Field key.

$value : string

Posted Value.

Tags
since
9.0.0

No longer allows storing IFRAME, which was allowed for "ShareThis" integration no longer found in core.

Return values
string

delete_template_action()

Delete template action.

protected delete_template_action(string $template_type) : mixed
Parameters
$template_type : string

Template type.

Return values
mixed

get_bcc_field()

Get the bcc field definition.

protected get_bcc_field() : array<string|int, mixed>
Return values
array<string|int, mixed>

get_cc_field()

Get the cc field definition.

protected get_cc_field() : array<string|int, mixed>
Return values
array<string|int, mixed>

get_must_use_css_styles()

Returns CSS styles that should be included with all HTML e-mails, regardless of theme specific customizations.

protected get_must_use_css_styles() : string
Tags
since
9.1.0
Return values
string

get_option_or_transient()

Get an option or transient for email preview.

protected get_option_or_transient(string $key[, mixed $empty_value = null ]) : mixed
Parameters
$key : string

Option key.

$empty_value : mixed = null

Value to use when option is empty.

Return values
mixed

get_preheader_field()

Get the preheader field definition.

protected get_preheader_field() : array<string|int, mixed>
Return values
array<string|int, mixed>

is_order_eligible_for_recovery()

Whether an order is in a state that warrants a recovery email.

protected is_order_eligible_for_recovery(WC_Order $order) : bool

The order must (a) be in one of the eligible statuses, (b) have lived in that state for at least ABANDONMENT_THRESHOLD_SECONDS (so we don't nudge customers who are actively still on the page), and (c) have a valid billing email — checkout-draft orders in particular can land in the eligible status without a recipient.

Single source of truth: called both by trigger() (defence-in-depth at send time) and by the manual-send dropdown gates. Partners can widen the eligible-status set via woocommerce_abandoned_cart_recovery_eligible_statuses and both paths will agree.

Parameters
$order : WC_Order

Order to evaluate.

Tags
since
11.0.0
Return values
bool

move_template_action()

Move template action.

protected move_template_action(string $template_type) : mixed
Parameters
$template_type : string

Template type.

Return values
mixed

save_template()

Save the email templates.

protected save_template(string $template_code, string $template_path) : mixed
Parameters
$template_code : string

Template code.

$template_path : string

Template path.

Tags
since
2.4.0
Return values
mixed

send_if_recipient()

Send the email when a recipient is available, regardless of the enabled setting.

protected send_if_recipient() : bool

This helper is intended for manually-triggered emails (e.g. invoice resend, POS receipts) that intentionally bypass the enabled/disabled check. It fires woocommerce_email_skipped with reason {@see} when no recipient is available so the outcome is still observable via the EmailLogger, and otherwise delegates to send().

Tags
since
10.9.0
Return values
boolWhether the email was sent successfully.

send_notification()

Send the email notification when enabled and a recipient is available.

protected send_notification() : bool

This is the standard helper used by trigger() methods. It checks whether the email is enabled and whether a recipient address exists, fires appropriate action hooks for the disabled or skipped outcome, and otherwise delegates to send() with the standard content parameters.

Subclasses that intentionally bypass the enabled check (e.g. manually-triggered invoice emails, POS receipts) should NOT call this method and should continue to call send() directly.

Tags
since
10.9.0
Return values
boolWhether the email was sent successfully.

set_defaults()

Set default required properties for each field.

protected set_defaults(array<string|int, mixed> $field) : array<string|int, mixed>
Parameters
$field : array<string|int, mixed>

Setting field array.

Return values
array<string|int, mixed>

supports_emogrifier()

Return if emogrifier library is supported.

protected supports_emogrifier() : bool
Tags
version
4.0.0
since
3.5.0
Return values
bool

apply_inline_style()

Apply inline styles to dynamic content using Emogrifier library (if supported).

private apply_inline_style(string|null $content) : string
Parameters
$content : string|null

Content that will receive inline styles.

Tags
since
10.2.0
Return values
string

clear_alt_body_field()

Clears the PhpMailer AltBody field, to prevent that content from leaking across emails.

private clear_alt_body_field() : void
Return values
void

get_block_email_html_content()

Gerenerates the HTML content for the email from a block based email.

private get_block_email_html_content() : string|null

and if so, it renders the block email content.

Return values
string|null