Automattic\WooCommerce\Internal\EmailEditor\WCTransactionalEmails

WCTransactionalEmailPostsGenerator::resolve_block_template_namepublic staticWC 10.8.0

Resolve the block template name for the given email.

Returns $email->template_block when set, otherwise derives it from $email->template_plain by replacing the plain segment with block (e.g. emails/plain/customer-invoice.php becomes emails/block/customer-invoice.php).

Method of the class: WCTransactionalEmailPostsGenerator{}

No Hooks.

Returns

String. The block template name, or an empty string if none can be resolved.

Usage

$result = WCTransactionalEmailPostsGenerator::resolve_block_template_name( $email ): string;
$email(WC_Email) (required)
The email object.

Changelog

Since 10.8.0 Introduced.

WCTransactionalEmailPostsGenerator::resolve_block_template_name() code WC 10.8.1

public static function resolve_block_template_name( $email ): string {
	if ( ! empty( $email->template_block ) ) {
		return (string) $email->template_block;
	}

	$template_plain = (string) $email->template_plain;
	if ( '' === $template_plain ) {
		return '';
	}

	return str_replace( 'plain', 'block', $template_plain );
}