Automattic\WooCommerce\Internal\EmailEditor

Integration::update_send_preview_email_rendered_datapublicWC 1.0

Filter email preview data used when sending a preview email.

Method of the class: Integration{}

No Hooks.

Returns

String. The updated preview data with placeholders replaced.

Usage

$Integration = new Integration();
$Integration->update_send_preview_email_rendered_data( $data );
$data(string) (required)
The preview data.

Integration::update_send_preview_email_rendered_data() code WC 10.3.6

public function update_send_preview_email_rendered_data( $data ) {
	$email_type = '';
	$post_body  = file_get_contents( 'php://input' );

	if ( $post_body ) {
		$decoded_body = json_decode( $post_body );

		if ( json_last_error() === JSON_ERROR_NONE && isset( $decoded_body->postId ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
			$post_id = absint( $decoded_body->postId ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase

			$email_type = WCTransactionalEmailPostsManager::get_instance()->get_email_type_from_post_id( $post_id );
			if ( ! empty( $email_type ) ) {
				return $this->update_email_preview_data( $data, $email_type );
			}
		}
	}
	return $data;
}