Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Matt Taylor 873 posts 2086 karma points
    May 18, 2011 @ 14:58
    Matt Taylor
    0

    Emailing a new customer their membership password

    I have seen that there is a pipeline task to create a new member if the customer is not already registered, CreateMemberForCustomerTask.

    It would be nice to email a new customer with their password and I'm sure this has been thought of and done already by someone.

    Is there something available already in uCommerce to help with this?
    If not, what would be the best approach...a custom pipeline task maybe?

    Regards,

    Matt

  • Matt Taylor 873 posts 2086 karma points
    May 25, 2011 @ 14:20
    Matt Taylor
    0

    Can this be done?

  • Søren Spelling Lund 1797 posts 2786 karma points
    May 25, 2011 @ 16:56
    Søren Spelling Lund
    0

    Hi Matt,

    The best way is a custom task or a modified version of the existing CreateMemberForCustomerTask in the checkout pipeline.

    The trouble is that by default passwords are encrypted in the database, so you'll have to gen the password and e-mail it one go.

    The CreateMemberForCustomerTask in the checkout pipeline already does this, but obviously doesn't send out the e-mail. What you can do is inherit the existing CreateMemberForCustomerTask and override the GeneratePassword method on the task.

    I whipped up a sample to do it. Basically what it does is:

    The CreateMemberAndSendPasswordTask class inherits the default task and overrides the GeneratePassword method. Because the key method, Execute, is not marked as virtual I'm using two classes to make it go: 1) A shell that only executes my custom task, and 2) the actual custom task, which overrides the GeneratePassword() method and sends the e-mail using the configured template. 

    public class CreateMemberAndSendPasswordTask
    {
        public PipelineExecutionResult Execute(PurchaseOrder order)
        {
            // New an instance of our custom task
            var task = new CreateMemberAndSendPasswordInternalTask();
    
            // Save the order for use in GeneratePassword to get the e-mail
            task.PurchaseOrder = order;
    
            return task.Execute(order);
        }
    }
    
    public class CreateMemberAndSendPasswordInternalTask : CreateMemberForCustomerTask
    {
        public PurchaseOrder PurchaseOrder { get; set; }
        public override string GeneratePassword()
        {
            string password = base.GeneratePassword();
    
            var customer = PurchaseOrder.Customer;
    
            // Build a list of parameters to pass to the e-mail service
            // Parameters are passed to the configured e-mail template with the key specified, 
            // e.g. MyWelcomeTemplate.apsx?password=<generatedPassword>&firstName=<firstName>&lastName=<lastName>
            // Can also be used in the subject in the form of {password}, {firstName}, {lastName}
            var parameters = new Dictionary<string, string>();
            parameters.Add("password", password);
            parameters.Add("firstName", customer.FirstName);
            parameters.Add("lastName", customer.LastName);
    
            var emailService = new EmailService();
            var emailProfile = SiteContext.Current.CatalogContext.CurrentCatalogSet.EmailProfiles.Single();
            emailService.Send(emailProfile, "WelcomeEmail", new MailAddress(PurchaseOrder.Customer.EmailAddress), parameters);
    
            return password;
        }
    
    }

  • Matt Taylor 873 posts 2086 karma points
    May 25, 2011 @ 17:58
    Matt Taylor
    0

    Great, so I'd just replace the call in the checkout pipeline to CreateMemberForCustomerTask with a call to CreateMemberAndSendPasswordTask.

    Sounds good.

    Thanks again,

    Matt

  • Søren Spelling Lund 1797 posts 2786 karma points
    May 25, 2011 @ 19:57
    Søren Spelling Lund
    0

    Yep. Forgot the registration. Let me know if you need help with that.

  • Robert 30 posts 110 karma points
    Nov 15, 2011 @ 12:15
    Robert
    0

    Hi Guys,

    Quick question about this thread.

    I've been given a website to off and have the website files. But I can't see any of the source code to make for example the change below. Its like it's been complied. Any idea of a link to the source or am I going about this the wrong way?

    Also any links to tutorials on user registration, basically I need users to register for an account then login. But from what I can tell ucommerce creates the account on order and doesn't email them there password(this is how I found this thread) any help would be greatful.

    Thanks

     

  • Matt Taylor 873 posts 2086 karma points
    Nov 15, 2011 @ 13:50
    Matt Taylor
    0

    You may find some code in the app_code directory.
    If not all the .Net code will have been compiled into an assembly in the bin folder.

    User registration is all handled by the .Net membership provider so you should use your favourite search engine to find out about that.

    All your questions seem to relate to .Net rather than Umbraco or uCommerce so you'll need a good undertanding of that first off.

    Matt

  • Søren Spelling Lund 1797 posts 2786 karma points
    Nov 29, 2011 @ 15:53
    Søren Spelling Lund
    0

    You can use standard Umbraco membership and handle customer like that. Creating member profiles for customers as part of check out is a simple way of handling the scenario where customers don't have upfront profiles. In your case it seems existing profiles should be linked to the purchase (which they will be if a match is found by email).

  • Tim 174 posts 398 karma points
    Jul 13, 2013 @ 15:43
    Tim
    0

    Just as a heads up to anyone else that has stumbled across this post looking for a way to create members and email them their password during the uCommerce checkout process, I've just blogged about it here: http://blogs.thesitedoctor.co.uk/tim/2013/07/13/How+To+Create+An+Umbraco+Member+And+Email+The+Customer+Their+Password+At+Checkout+Using+UCommerce.aspx

    Tim

Please Sign in or register to post replies

Write your reply to:

Draft