Automattic\WooCommerce\StoreApi\Routes\V1

Checkout::should_create_customer_account()privateWC 1.0

Check request options and store (shop) config to determine if a user account should be created as part of order processing.

{} Это метод класса: Checkout{}

Хуков нет.

Возвращает

true|false. True if a new user account should be created.

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

// private - только в коде основоного (родительского) класса
$result = $this->should_create_customer_account( $request );
$request(\WP_REST_Request) (обязательный)
The current request object being handled.

Код Checkout::should_create_customer_account() WC 6.8.0

private function should_create_customer_account( \WP_REST_Request $request ) {
	if ( is_user_logged_in() ) {
		return false;
	}

	// Return false if registration is not enabled for the store.
	if ( false === filter_var( wc()->checkout()->is_registration_enabled(), FILTER_VALIDATE_BOOLEAN ) ) {
		return false;
	}

	// Return true if the store requires an account for all purchases. Note - checkbox is not displayed to shopper in this case.
	if ( true === filter_var( wc()->checkout()->is_registration_required(), FILTER_VALIDATE_BOOLEAN ) ) {
		return true;
	}

	// Create an account if requested via the endpoint.
	if ( true === filter_var( $request['create_account'], FILTER_VALIDATE_BOOLEAN ) ) {
		// User has requested an account as part of checkout processing.
		return true;
	}

	return false;
}