Automattic\WooCommerce\Internal\StockNotifications\Emails

EmailActionController::process_verification_actionprivateWC 1.0

If the verification key matches, it updates the notification status to active.

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

Возвращает

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

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

// private - только в коде основоного (родительского) класса
$result = $this->process_verification_action( $notification, $action_key ): void;
$notification(Notification) (обязательный)
The notification to process.
$action_key(строка) (обязательный)
The action key to verify.

Код EmailActionController::process_verification_action() WC 11.0.1

private function process_verification_action( Notification $notification, string $action_key ): void {
	if ( $notification->check_verification_key( $action_key ) ) {
		// Guard against re-hits of a still-valid verification URL (double-click, email prefetch,
		// link-scanner bots). Without this, each hit would re-dispatch the verified email.
		if ( NotificationStatus::ACTIVE === $notification->get_status() ) {
			return;
		}

		$notification->set_status( NotificationStatus::ACTIVE );
		$notification->set_date_confirmed( time() );
		$notification->save();

		/**
		 * Action: woocommerce_customer_stock_notifications_verified
		 *
		 * Fires after a stock-notification signup has been verified via the
		 * double opt-in email link. Mirrors `woocommerce_customer_stock_notifications_signup`.
		 *
		 * @since 10.9.0
		 *
		 * @param Notification $notification The notification.
		 */
		do_action( 'woocommerce_customer_stock_notifications_verified', $notification );

		$this->email_manager->send_verified_email( $notification );

		// We need a cookie-based session for notices to work on frontend pages.
		if ( WC()->session instanceof \WC_Session_Handler && ! WC()->session->has_session() ) {
			WC()->session->set_customer_session_cookie( true );
		}

		$product = wc_get_product( $notification->get_product_id() );

		/* translators: %s is product name */
		$notice_text = sprintf( esc_html__( 'Successfully verified stock notifications for "%s".', 'woocommerce' ), $product->get_name() );
		wc_add_notice( $notice_text );
		/**
		 * `woocommerce_customer_stock_notification_verified_redirect_url` filter.
		 *
		 * @since 10.2.0
		 *
		 * @param  string  $url
		 * @return string
		 */
		$url = apply_filters( 'woocommerce_customer_stock_notification_verified_redirect_url', get_permalink( wc_get_page_id( 'shop' ) ) );
		wp_safe_redirect( $url );
		exit;
	}
}