Automattic\WooCommerce\StoreApi\Routes\V1
Checkout::should_create_customer_account()
Check request options and store (shop) config to determine if a user account should be created as part of order processing.
Method of the class: Checkout{}
No Hooks.
Return
true|false
. True if a new user account should be created.
Usage
// private - for code of main (parent) class only $result = $this->should_create_customer_account( $request );
- $request(\WP_REST_Request) (required)
- The current request object being handled.
Checkout::should_create_customer_account() Checkout::should create customer account code WC 7.7.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; }