WC_Email::get_headerspublicWC 1.0

Get email headers.

Method of the class: WC_Email{}

Hooks from the method

Returns

String.

Usage

$WC_Email = new WC_Email();
$WC_Email->get_headers();

WC_Email::get_headers() code WC 10.8.1

public function get_headers() {
	$header = 'Content-Type: ' . $this->get_content_type() . "\r\n";

	// For order notification emails sent to admin, always use customer's billing email as reply-to.
	if ( in_array( $this->id, array( 'new_order', 'cancelled_order', 'failed_order' ), true ) ) {
		if ( $this->object && $this->object->get_billing_email() && ( $this->object->get_billing_first_name() || $this->object->get_billing_last_name() ) ) {
			$header .= 'Reply-to: ' . $this->object->get_billing_first_name() . ' ' . $this->object->get_billing_last_name() . ' <' . $this->object->get_billing_email() . ">\r\n";
		}
	} else {
		// Check if custom reply-to is enabled and configured for non-admin notification emails.
		$reply_to_enabled = $this->get_reply_to_enabled();
		$reply_to_address = $this->get_reply_to_address();
		$reply_to_name    = $this->get_reply_to_name();

		if ( $reply_to_enabled && ! empty( $reply_to_address ) && is_email( $reply_to_address ) ) {
			$reply_to_name = ! empty( $reply_to_name ) ? $reply_to_name : $this->get_from_name();
			$header       .= 'Reply-to: ' . $reply_to_name . ' <' . $reply_to_address . ">\r\n";
		} elseif ( $this->get_from_address() && $this->get_from_name() ) {
			$header .= 'Reply-to: ' . $this->get_from_name() . ' <' . $this->get_from_address() . ">\r\n";
		}
	}

	if ( FeaturesUtil::feature_is_enabled( 'email_improvements' ) ) {
		$cc = $this->get_cc_recipient();
		if ( ! empty( $cc ) ) {
			$header .= 'Cc: ' . sanitize_text_field( $cc ) . "\r\n";
		}

		$bcc = $this->get_bcc_recipient();
		if ( ! empty( $bcc ) ) {
			$header .= 'Bcc: ' . sanitize_text_field( $bcc ) . "\r\n";
		}
	}

	return apply_filters( 'woocommerce_email_headers', $header, $this->id, $this->object, $this );
}