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. Remove email verification when new user register
  46. How to update variable product stock status with code
  47. Woocommerce Product Image and Thumbnails custom function
  48. Create WooCommerce new order with specific ID
  49. is_user_logged_in() always returns false for woocommerce_login_redirect
  50. WordPress ‘on behalf of’ email
  51. How to change a column width on WooCommerce orders page (Admin)
  52. WooCommerce Shop Orders by Date
  53. Show list of woo commerce orders where particular zip code exists using pre_get_posts?
  54. display first sale product in shop
  55. woocommerce cart item remove ajax not working in hosted site [closed]
  56. Set woocommerce product price based on dealer location [closed]
  57. How can I custom order the product display?
  58. WordPress plugin cloak link [closed]
  59. Woocommerce REST API – updating an order changes custom tax calculations
  60. How to list all WC products by their attributes values?
  61. How to override the title tag for woocommerce endpoints?
  62. How to rewrite product permalinks in Woocommerce to use category slugs
  63. How to re-arrange this hooked content?
  64. Pre filter woocommerce products to remove a certain category of products
  65. WooCommerce Stripe Plugin not showing up in settings [closed]
  66. Woocommerce – Change the template?
  67. Wooocommerce disable check_cart_item_stock if cart item has specific meta
  68. Force meta data on specific product type
  69. WooCommerce plaintext mail doesn’t display currency symbol
  70. Woocommerce, finding the ordinal number of a purchase for a certain product
  71. WP/WooCommerce multisite with polylang, product duplication between websites [closed]
  72. WooCommerce add_to_cart
  73. WooCommerce Simple Product Options List
  74. Add custom body tag if product is out of stock
  75. Functions.php change for Woocommerce not working
  76. Woocommerce replace product page image with product tabs [closed]
  77. How to get all customers cart from woocommerce API?
  78. WooCommerce login redirect based on cart
  79. Woocommerce + Google Analytics (Conversion Rate Not Working)
  80. send order detail to swiftpos
  81. WordPress Woocommerce REST API JSON Error
  82. data-value for custom woocommerce field showing in code but not visable on page load
  83. Update user meta when customer update their first name
  84. call_user_func_array() expects parameter 1 to be a valid callback, class ‘WC_Rapyd’ does not have a method ‘install’
  85. How can we find a WooCommerce shop bottleneck? (only when cart is full)
  86. Conditional for product attribute page
  87. Setting Page Visibility for WooCommerce Default Page Doesn’t Work
  88. Deleted products from woocommerce are still in the database
  89. Overriding Plugin function in your child theme
  90. Files names changed (with strange characters) after being uploaded to cpanel
  91. woocommerce_add_to_cart custom function called several times
  92. How to fix spacing in address tab in my account page
  93. Adding time of order to Admin email for new order
  94. Hide add to cart when product variation has no price or is unavailable
  95. How to get the WooCommercer product variation image
  96. How can I hide the entire “Shipping Details” block on the admin side of Woocommerce? [closed]
  97. How do I put woocommerce cart page to my checkout page? [closed]
  98. Modify existing code to show user nickname in woocoomerce order email instead of user_login
  99. How to prevent woocommerce product tag field from update?
  100. WooCommerce custom SVG coloring tool [closed]
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
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 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