Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation

AbstractOrderConfirmationBlock::is_email_verifiedprotectedWC 1.0

Returns true if the email has been verified (posted email matches given order email).

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

Хуков нет.

Возвращает

true|false.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->is_email_verified( $order );
$order(WC_Order) (обязательный)
Order object.

Код AbstractOrderConfirmationBlock::is_email_verified() WC 9.9.4

protected function is_email_verified( $order ) {
	// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
	if ( empty( $_POST ) || ! isset( $_POST['email'], $_POST['_wpnonce'] ) ) {
		return false;
	}

	$nonce_value = sanitize_key( wp_unslash( $_POST['_wpnonce'] ?? '' ) );

	if ( ! wp_verify_nonce( $nonce_value, 'wc_verify_email' ) && ! wp_verify_nonce( $nonce_value, 'wc_create_account' ) ) {
		return false;
	}

	return $order->get_billing_email() && sanitize_email( wp_unslash( $_POST['email'] ?? '' ) ) === $order->get_billing_email();
}