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.

  • Byron Delgado 47 posts 70 karma points
    Sep 20, 2011 @ 14:22
    Byron Delgado
    0

    How to relate existing Umbraco members to uCommerce Customer?

     

    The site we are working on has to be able to register members not only in the ecommerce process but in other areas. 

    How do I relate an exisitng Umbraco Member to a uCommerce customer, is it okay if in the checkout process I create a new Customer?. My code look like this:

                var basketPurchaseOrder = SiteContext.Current.OrderContext.GetBasket().PurchaseOrder;
    
                //Umbraco Member wrapper including properties.
                ECommerceMember eMember = UmbracoMembers.GetCurrentMember();
    
                bool existInUcommerce = Customer.Exists(c => c.UmbracoMemberId == eMember.UmbracoId);
                if(!existInUcommerce)
                {
                    Customer customer = new Customer
                                            {
                                                UmbracoMemberId = eMember.UmbracoId,
                                                FirstName = eMember.Firstname,
                                                LastName = eMember.Surname,
                                                EmailAddress = eMember.Email,
                                                PhoneNumber = eMember.Telephone
                                            };
    
    
                    customer.AddAddress(new Address
                                            {
                                                AddressName = "Address name 1",
                                                FirstName = eMember.Firstname,
                                                LastName = eMember.Surname,
                                                EmailAddress = eMember.Email,
                                                PhoneNumber = eMember.Telephone,
                                                Country = Country.All().FirstOrDefault(),
                                                PostalCode = "Postal Code",
                                                City = "City",
                                                CompanyName = eMember.Organization,
                                                Line1 = "Line 1",
                                                Line2 = "Line 2"
                                            });
    
                    customer.Save();
    
                    basketPurchaseOrder.Customer = customer;
                    basketPurchaseOrder.Save();
                }
    
                CallBasketPipeline();
                var chekoutPipeline = PipelineFactory.Create<PurchaseOrder>("Checkout"); //"Checkout" is the default pipeline implemented in \umbraco\UCommerce\Pipelines\Checkout.config
    
                if (chekoutPipeline.Execute(basketPurchaseOrder) != PipelineExecutionResult.Error)
                {
                    return true;
                }
    
                Log.Add(LogTypes.Custom, 0, "----> Error in checout pipeline: {0}");
                return false;
    
    Is there a better way?
    Any help greatly appreciatted.

     

  • Søren Spelling Lund 1797 posts 2786 karma points
    Sep 21, 2011 @ 19:27
    Søren Spelling Lund
    1

    You can have uCommerce do it for you automatically by checking "Create Members for Customers".

    If a member doesn't exist when the customer checks out a new one will be created with the specified type in the specified member group. If a member is logged in that member will be set on the customer.

  • Byron Delgado 47 posts 70 karma points
    Sep 21, 2011 @ 19:30
    Byron Delgado
    0

    Thanks. I guess this will work only for creating new customers, what about existing umbraco members before they become customers?

  • Søren Spelling Lund 1797 posts 2786 karma points
    Sep 21, 2011 @ 22:10
    Søren Spelling Lund
    0

    The feature is poorly named. If a member is logged in uCommerce will use that instead of creating a new one.

  • paola 1 post 21 karma points
    May 15, 2014 @ 18:47
    paola
    0

    I dont see the same structure for the new umbraco interface. Does the functionality still in threre?

  • Søren Spelling Lund 1797 posts 2786 karma points
    May 21, 2014 @ 10:30
    Søren Spelling Lund
    0

    It's still there. In Umbraco 7 there are no sections but if you look at the store level you'll see the options are still there.

Please Sign in or register to post replies

Write your reply to:

Draft