Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Allow WooCommerce existing customers to checkout without being logged in [closed]

You would allow the user to fill the email, use it to find the user id at the database and then use the id for the order.

One possible solution is to replace function wc_create_new_customer( $email, $username="", $password = '', $args = array() ) with a custom function.

This is where the function is called, all your custom function needs to do is find the correct user_id.

    protected function process_customer( $data ) {
        $customer_id = apply_filters( 'woocommerce_checkout_customer_id', get_current_user_id() );

        if ( ! is_user_logged_in() && ( $this->is_registration_required() || ! empty( $data['createaccount'] ) ) ) {
            $username    = ! empty( $data['account_username'] ) ? $data['account_username'] : '';
            $password    = ! empty( $data['account_password'] ) ? $data['account_password'] : '';
            $customer_id = wc_create_new_customer(
                $data['billing_email'],
                $username,
                $password,
                array(
                    'first_name' => ! empty( $data['billing_first_name'] ) ? $data['billing_first_name'] : '',
                    'last_name'  => ! empty( $data['billing_last_name'] ) ? $data['billing_last_name'] : '',
                )
            );

            if ( is_wp_error( $customer_id ) ) {
                throw new Exception( $customer_id->get_error_message() );
            }

            wc_set_customer_auth_cookie( $customer_id );

            // As we are now logged in, checkout will need to refresh to show logged in data.
            WC()->session->set( 'reload_checkout', true );

            // Also, recalculate cart totals to reveal any role-based discounts that were unavailable before registering.
            WC()->cart->calculate_totals();
        }

Hope this helps to point you in the right direction.

Cheers,
Gabriel

Related Posts:

  1. Why is my WordPress login credentials missing, but work with WooCommerce?
  2. Change WooCommerce registration form/way?
  3. Username field is not shown in Woocommerce’s registration contact form
  4. Custom Redirect after registration in WooCommerce
  5. Which hook should I use to capture $_POST(‘password’) via profile update and password reset
  6. Force User Registration before visitng Checkout Page
  7. Register a new user on wooCommerce using Rest API
  8. WooCommerce: “account is already registered with your email address”
  9. How to delete all customer user account that haven’t placed a single order?
  10. Auto generate user email while registration
  11. Woocommerce check if email already created order recently [closed]
  12. WooCommerce Registration redirect based on page ID
  13. Send admin new order email to logged in user as well
  14. Block Disposable Emails on Woocommerce Registration
  15. Clients with empty username are not receiving request new password email
  16. Show password while you are typing it on the “my account” login page
  17. WooCommerce Admin order – Only run action if user is loaded
  18. Woocommerce Register Error
  19. I want to store user password (during registration) in an other table in the same database in addition to the user table MD5 Hash
  20. Make e-Mail optional on Woocommerce sign up
  21. Switch to user link shortcode
  22. Assign user role by text field in WordPress (Woocommerce) [closed]
  23. Show notice to user based on User Meta
  24. Impossible to create a new WooCommerce customer using Rest API
  25. Add custom field address_3 before city in user profile
  26. Registration roles
  27. How to merge 2 accounts with same email address after merge of 2 woocommerce databases
  28. How to send Woocommerce Customer Details (Name, Email and Phone Number) to Admin upon signup
  29. WordPress user ID prefix
  30. Get user active posts randomly
  31. Woocommerce customer role doesn’t change if user is already a subscriber [closed]
  32. Redirect After Registration on Specific Link
  33. Custom Registration Fields woocommerce
  34. Custom registration fields not appearing in user info
  35. Some Admin disappeared
  36. If YITH Wishlist page is set to the WooCommerce my-account endpoint, the endpoints stop working all together. Any solution?
  37. how can i inform other users about new user registration? [closed]
  38. DatePicker in Woocommerce (My Account) Registration [closed]
  39. Login page so wide [closed]
  40. Want to add Number of Products added by each shop manager in users list
  41. Remove login fields from /customer-account page [closed]
  42. How to handle WordPress account for terminated employee
  43. Add a product for all users based on a condition (WooCommerce)
  44. My account page, don’t show the complete “Registration form”
  45. Email Woocommerce customer a link to login and set a password for their automatically created account
  46. How to hook in to WooCommerce Related Products
  47. WordPress Migration
  48. Integration widget Mondial Relay Js
  49. Remove link for Woocommerce product tags
  50. WooCommerce Class dosen’t exist
  51. woocommerce Shortcodes – Change display between mobile and Desktop
  52. creating number of database entries based on users numerical input
  53. Replace product link with just product name on WooCommerce downloads page
  54. Import download attachment from woocommerce product
  55. Increase load-out-page speed
  56. How to check which shortcode is using my template?
  57. WooCommerce Stucked (?) – Edit dimensions
  58. Users getting linked unwanted to main mu in WordPress multisite (WPMU)
  59. show multiple product photos on WooCommerce single page
  60. Use Product Attribute in conditional tag
  61. Woocommerce Product category base same as product base causes 404
  62. Categories and products in cart Woocommerce
  63. Update products with curl (bash)
  64. Woocommerce: Unique price for individual basket items
  65. Hide add to cart when product variation has no price or is unavailable
  66. Admin – Custom Post Type in WooCommerce menu – how to control menu order
  67. Facing issue in Woocommerce 3.3 version in wordpress
  68. SyntaxError: unterminated string literal – if WordPress Debug in wp-config is set to true
  69. getting attributes in a product loop
  70. How Fragile Is DB if I Upload Completely Updated Files
  71. Broken 302 redirection for product subcategory (Woocommerce, Apache)
  72. Can I get some product is virtual in Woocommerce by hook?
  73. Woocommerce order_complete email dont send after changing order status via sql
  74. Removing storefront-sorting div from the before section of Shop page
  75. Site with WooCommerce section moved to HTTPS – all pages except home and main store are 404s
  76. syntax error – woocommerce
  77. Multiple quantities with options
  78. How to on/off woocommerce filter with redux framework [closed]
  79. (WooCommerce) Conflict with template – Can’t load payment methods
  80. Hook woocommerce price in backend order edition
  81. Website Tablet Check Out Field Issue
  82. How to change the link of product menu from wordpress admin panel
  83. WooCommerce order created via REST – sending the date_created along
  84. User / membership Plugin [closed]
  85. how to add custom reviews button in woocommerce order complete generated mail
  86. Storing data to database and user registration
  87. Click Count on Download a File
  88. delete cart item from the carts when user login from other system
  89. get_posts only getting most recent product
  90. How to add coupon expiry date into the followup emails?
  91. How to only show featured products in wooCommerce using function.php function
  92. How to insert link, with lightbox, that opens specific page content only
  93. Add youtube embed to woocommerce variations
  94. Can’t activate a user on multisite install
  95. WooCommerce – Large number of product variations (200+)
  96. how can i import the csv file in wordpress woocommerce.?
  97. Add custom link/pop up under variations dropdown
  98. Problem in woocommerce.The option “Add product image” is gone.Please help me!
  99. Insert user register into my own user table instead of wp own user
  100. some products free and some product is not free for shipping
Categories woocommerce-offtopic Tags account, user-registration, users, woocommerce-offtopic
How to modify WCMP Rest API response?
redirect Login problems

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Post Navigation Elementor
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • WPFacet multiple loop displaying duplicate content
  • Get the name of the template/*html file used
  • Fix: WordPress.DB.PreparedSQL.NotPrepared Plugin Check (PCP)
  • Removing unnecessary CSS and JS code from wp_head()
  • hexagonal image gallery. Am I on the right track? [closed]
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress