Automattic\WooCommerce\Internal\EmailEditor
Integration::update_send_preview_email_rendered_data
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, $post );
- $data(string) (required)
- The preview data.
- $post(WP_Post) (required)
- The post object.
Integration::update_send_preview_email_rendered_data() Integration::update send preview email rendered data code WC 10.9.4
public function update_send_preview_email_rendered_data( $data, $post ) {
$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 );
}
}
} elseif ( ! empty( $post ) && $post instanceof \WP_Post ) {
$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, $post->ID );
}
}
return $data;
}