#how to upgrade a customer from guest ot registered

3 messages · Page 1 of 1 (latest)

tranquil bramble
#

I have been reading the documentation and I don't see a clear way to transform a guest into a registered customer. What is the best approach in the following business case: After his first order as guest, I send an email suggesting to join a loyalty program with benefits. When he accepts, I need to allow him to create his password. If i create a new customer as in the doc, how do I transfer his past orders ? Thanks

hexed topaz
#

You can send them an email and register them usin a custom API

random snow
# tranquil bramble I have been reading the documentation and I don't see a clear way to transform a...

What you’re looking for isn’t really about “transferring” orders in a manual way, it’s more about linking identity properly.
When a guest places an order, Medusa still stores the email on the order, it’s just not attached to a registered customer record yet. So when the user accepts your loyalty program invitation, you can create a customer using the same email address. After that, you can implement a small custom backend route that finds all previous orders with that email and updates their customer_id to the newly created customer’s id. That way, the past orders become part of their account history naturally.
For the password part, instead of setting it directly, it’s better to trigger a proper account activation or password setup flow so they can securely define their own credentials.
This approach keeps the data clean and avoids duplicating customers, while making sure their order history stays consistent once they register.