Automattic\WooCommerce\Internal\Admin\EmailPreview

EmailPreview::set_email_type()publicWC 1.0

Set the email type to preview.

Метод класса: EmailPreview{}

Хуки из метода

Возвращает

null. Ничего (null).

Использование

$EmailPreview = new EmailPreview();
$EmailPreview->set_email_type( $email_type );
$email_type(строка) (обязательный)
Email type.

Код EmailPreview::set_email_type() WC 9.6.1

public function set_email_type( string $email_type ) {
	$emails = WC()->mailer()->get_emails();
	if ( ! in_array( $email_type, array_keys( $emails ), true ) ) {
		throw new \InvalidArgumentException( 'Invalid email type' );
	}
	$this->email_type = $email_type;
	$this->email      = $emails[ $email_type ];

	$order = $this->get_dummy_order();
	$this->email->set_object( $order );
	$this->email->placeholders = array_merge(
		$this->email->placeholders,
		$this->get_placeholders( $order )
	);

	/**
	 * Allow to modify the email object before rendering the preview to add additional data.
	 *
	 * @param WC_Email $email The email object.
	 *
	 * @since 9.6.0
	 */
	$this->email = apply_filters( 'woocommerce_prepare_email_for_preview', $this->email );
}