Automattic\WooCommerce\Internal\EmailEditor

EmailApiController::get_email_datapublicWC 1.0

Returns the data from wp_options table for the given post.

Method of the class: EmailApiController{}

No Hooks.

Returns

Array. - The email data.

Usage

$EmailApiController = new EmailApiController();
$EmailApiController->get_email_data( $post_data ): array;
$post_data(array) (required)
- Post data.

EmailApiController::get_email_data() code WC 10.3.6

public function get_email_data( $post_data ): array {
	$email_type = $this->post_manager->get_email_type_from_post_id( $post_data['id'] );
	$email      = $this->get_email_by_type( $email_type ?? '' );

	// When the email type is not found, it means that the email type is not supported.
	if ( ! $email ) {
		return array(
			'subject'         => null,
			'subject_full'    => null,
			'subject_partial' => null,
			'preheader'       => null,
			'default_subject' => null,
			'email_type'      => null,
			'recipient'       => null,
			'cc'              => null,
			'bcc'             => null,
		);
	}

	$form_fields = $email->get_form_fields();
	$enabled     = $email->get_option( 'enabled' );
	return array(
		'enabled'         => is_null( $enabled ) ? $email->is_enabled() : 'yes' === $enabled,
		'is_manual'       => $email->is_manual(),
		'subject'         => $email->get_option( 'subject' ),
		'subject_full'    => $email->get_option( 'subject_full' ), // For customer_refunded_order email type because it has two different subjects.
		'subject_partial' => $email->get_option( 'subject_partial' ),
		'preheader'       => $email->get_option( 'preheader' ),
		'default_subject' => $email->get_default_subject(),
		'email_type'      => $email_type,
		// Recipient is possible to set only for the specific type of emails. When the field `recipient` is set in the form fields, it means that the email type has a recipient field.
		'recipient'       => array_key_exists( 'recipient', $form_fields ) ? $email->get_option( 'recipient', get_option( 'admin_email' ) ) : null,
		'cc'              => $email->get_option( 'cc' ),
		'bcc'             => $email->get_option( 'bcc' ),
	);
}