File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -299,6 +299,27 @@ public function handle_account_registration( $customer_id ) {
299
299
delete_user_meta ( $ user_id , 'wc_apa_ownership_verification_code ' );
300
300
}
301
301
302
+ if ( ! $ customer_id ) {
303
+ $ username = ! empty ( $ data ['account_username ' ] ) ? $ data ['account_username ' ] : '' ;
304
+ $ password = ! empty ( $ data ['account_password ' ] ) ? $ data ['account_password ' ] : '' ;
305
+
306
+ $ customer_id = wc_create_new_customer (
307
+ $ data ['billing_email ' ],
308
+ $ username ,
309
+ $ password ,
310
+ array (
311
+ 'first_name ' => ! empty ( $ data ['billing_first_name ' ] ) ? $ data ['billing_first_name ' ] : '' ,
312
+ 'last_name ' => ! empty ( $ data ['billing_last_name ' ] ) ? $ data ['billing_last_name ' ] : '' ,
313
+ )
314
+ );
315
+
316
+ if ( is_wp_error ( $ customer_id ) ) {
317
+ throw new Exception ( $ customer_id ->get_error_message () );
318
+ }
319
+
320
+ $ this ->set_customer_id_for_buyer ( $ buyer_id , $ customer_id );
321
+ }
322
+
302
323
wc_set_customer_auth_cookie ( $ customer_id );
303
324
304
325
// As we are now logged in, checkout will need to refresh to show logged in data.
You can’t perform that action at this time.
0 commit comments