Save customers on order saved

Posted in General by Adrian Ursu Mon Mar 14 2016 20:55:40 GMT+0000 (UTC)·2·Viewed 1,270 times

Hi, I need to know how to save customers on order save. I have activated the "Enable customer accounts" option on store settings. I am using Merchello with Bazaar 1.14. Thanks, Adrian
Rusty Swayne
Mar 16, 2016

Customers are tied to Umbraco membership - so in the Bazaar, if the user has not created a membership account prior to checking out, the checkout is done with an anonymous customer. I think what you are trying to do is create a customer after a checkout has been completed and then update the invoice to include the customer key so that it is tied in the back office. This is possible, but will require some custom coding on your part.

I've done it before using the Invoice.Saving event handler.

  • First check if the customer is present - this will be apparent if the invoice has a customer key.
  • If not, check to see if a customer exists by login name (using the CustomerService and bill to email address as the login name).
  • If a customer is found via the service, you can use that customer's key, but you should understand the implications as in this case it is possible that someone other than the customer is checking out using the original customer's email address. Sending an email to the customer at this point with a link that includes the customer key and the invoice key that they click to make the association may be a better way to go - something like "We've received an anonymous order using your email address. Please confirm this is you ... or something"
    • If the customer record is not found, you can either create the customer directly using the service or better create an Umbraco member using a generated password, find the customer that is created via events and then grab the customer key to update the invoice in the .Saving handler. In the later case, sending the user an email with the generated password also makes sense.
darren mcgrath
Aug 23, 2017

Hi Rusty, This is exactly what I'm trying to do also.. Do you have the code for this? I am finding it very hard to find the correct place to extend classes / create custom events in Umbraco / Merchello.

Best wishes... D

  
Markdown is allowed