Automattic\WooCommerce\Internal\StockNotifications\Emails

EmailActionController::process_verification_actionprivateWC 1.0

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

Method of the class: EmailActionController{}

Returns

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->process_verification_action( $notification, $action_key ): void;
$notification(Notification) (required)
The notification to process.
$action_key(string) (required)
The action key to verify.

EmailActionController::process_verification_action() code WC 10.3.6

private function process_verification_action( Notification $notification, string $action_key ): void {
	if ( $notification->check_verification_key( $action_key ) ) {
		$notification->set_status( NotificationStatus::ACTIVE );
		$notification->set_date_confirmed( time() );
		$notification->save();

		// We need session for notices to work.
		if ( ! WC()->session->has_session() ) {
			// Generate a random customer ID.
			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 );
	}
}