Automattic\WooCommerce\Internal\CustomerEmailVerification

VerificationController::render_promptpublicWC 11.0.0

Render the verification prompt notice on the My Account "Orders" panel.

Within the rate-limit window a link was sent recently, so the prompt points the customer to their inbox and offers no immediate resend; otherwise it carries the "confirm email" call to action.

Method of the class: VerificationController{}

No Hooks.

Returns

null. Nothing (null).

Usage

$VerificationController = new VerificationController();
$VerificationController->render_prompt(): void;

Changelog

Since 11.0.0 Introduced.

VerificationController::render_prompt() code WC 11.0.0

public function render_prompt(): void {
	if ( ! $this->should_show_prompt() ) {
		return;
	}

	$user_id       = get_current_user_id();
	$seconds_since = $this->service->seconds_since_last_key( $user_id );

	if ( null !== $seconds_since && $seconds_since <= self::SEND_RATE_LIMIT ) {
		// A just-sent/throttled result notice (from the redirect) already points to the inbox this
		// page load, so don't print a second "check your inbox" alongside it.
		// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- display-only, no state change.
		if ( ! isset( $_GET[ self::NOTICE_PARAM ] ) ) {
			wc_print_notice(
				esc_html__( 'Confirm your email address to check for past orders. A confirmation link was sent recently — please check your inbox.', 'woocommerce' ),
				'notice'
			);
		}
		return;
	}

	$send_url = wp_nonce_url(
		add_query_arg( self::SEND_PARAM, '1', wc_get_account_endpoint_url( 'orders' ) ),
		self::SEND_NONCE_ACTION
	);

	$notice = sprintf(
		'<a href="%2$s" class="button wc-forward">%3$s</a> %1$s',
		esc_html__( 'Confirm your email address to check for past orders and link them to your account.', 'woocommerce' ),
		esc_url( $send_url ),
		esc_html__( 'Confirm email address', 'woocommerce' )
	);

	wc_print_notice( $notice, 'notice' );
}