1

So,

I am building a website in react using Wordpress headless server with WooCommerce plugin.

I have found that to create a new customer, you have to use the WooCommerce API: https://woocommerce.github.io/woocommerce-rest-api-docs/#create-a-customer

But this is only creating a new customer.

What I need is to let the user to be able to register its account through a signup to become a customer. So I was planning to use: https://wordpress.org/plugins/wp-rest-user/

So my use case is to have the signup pop-up coming up and entering the name, password and email and then it create an account on Wordpress and the user become a customer for WooCommerce.

Do I have to do :

1- Create an account with Wordpress API to register the new user.

2- Create a customer using the WooCommerce API

My concerns is that how do I make sure that the user newly created is also a new customer. I do not want to have 2 differents user.

Regards Sebastien

1
  • I'm not an expert, but I think a WooCommerce customer is just a WordPress user with role 'customer'. So I'm not sure what the difference is between using the WooCommerce API and the WordPress API here? (Generally new WordPress users are emailed a new password, they don't choose them anymore, but I don't know if WooCommerce does that differently.)
    – Rup
    Aug 27, 2020 at 16:50

1 Answer 1

0

If you create a new customer using the WooCommerce REST API, it will create a new WordPress user of the role Customer. Email is unique, a new customer cannot be added if his/her email is used by another WordPress user whether a customer or not. I tested that using API.

Regarding password, I still did not receive an email with it. I have my own WP deployment, and still no email is working.

What I need to look for next is how to authenticate a customer using the API to grant my customers thought my app.

4
  • "I have my own WP deployment, and still no email is working." - how have you set up email? By default WordPress will try and send to a local SMTP server I think to relay on, which you probably don't have, so at the very least you'll need to configure that to use an SMTP server provided by your host. Or I find it simpler to use a third-party mail API plugin instead.
    – Rup
    Oct 21, 2021 at 9:31
  • But you've posted this as an answer to Seb's question whereas it sounds like this is actually another request for help?
    – Rup
    Oct 21, 2021 at 9:31
  • 1
    "What I need to look for next is how to authenticate a customer using the API" - recent WordPress added per-user application passwords for this, or there are good plugins to do this already e.g. the JWT plugin is popular I think. Or AFAICR WooCommerce has its own REST API authentication built in too.
    – Rup
    Oct 21, 2021 at 9:34
  • My first paragraph was answering his question. I added it as an answer because I tested it myself on my API, so I wanted him to know. Because I'm still half-way in my solution, I just mentioned that. Oct 21, 2021 at 13:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.