WooCommerce Code Reference

Send_Preview_Email

Class Send_Preview_Email

This class is responsible for handling the functionality to send preview emails. It is part of the email editor integrations utilities.

Table of Contents

$personalizer  : Personalizer
Instance of the Personalizer class used for rendering personalization tags.
$renderer  : Renderer
Instance of the Renderer class used for rendering the editor emails.
__construct()  : mixed
Send_Preview_Email constructor.
render_html()  : string
Renders the HTML content of the post
send_email()  : bool
Sends an email preview.
send_preview_email()  : bool
Sends a preview email.
set_mail_content_type()  : string
Sets the mail content type. Used by $this->send_email.
set_personalize_content()  : string
Personalize the content.
fetch_post()  : WP_Post
Fetches a post_id post object based on the provided post ID.
validate_data()  : void
Validates the provided data array.

Properties

Methods

send_email()

Sends an email preview.

public send_email(string $to, string $subject, string $body) : bool
Parameters
$to : string

The recipient email address.

$subject : string

The subject of the email.

$body : string

The body content of the email.

Return values
boolReturns true if the email was sent successfully, false otherwise.

send_preview_email()

Sends a preview email.

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

The data required to send the preview email.

Tags
throws
Exception

If the data is invalid.

Return values
boolReturns true if the preview email was sent successfully, false otherwise.

set_mail_content_type()

Sets the mail content type. Used by $this->send_email.

public set_mail_content_type(string $content_type) : string
Parameters
$content_type : string

The content type to be set for the mail.

Return values
stringThe content type that was set.

fetch_post()

Fetches a post_id post object based on the provided post ID.

private fetch_post(int $post_id) : WP_Post
Parameters
$post_id : int

The ID of the post to fetch.

Tags
throws
Exception

If the post is invalid.

Return values
WP_PostThe WordPress post object.

validate_data()

Validates the provided data array.

private validate_data(array<string|int, mixed> $data) : void
Parameters
$data : array<string|int, mixed>

The data array to be validated.

Tags
throws
InvalidArgumentException

If the data is invalid.

Return values
void