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.

  • Ivan Saric 40 posts 89 karma points
    Feb 26, 2014 @ 13:06
    Ivan Saric
    0

    Billing address problem

    What I'm doing wrong, I need to register new customer with billing information on one page and that on second page to display this billing address but TransactionLibrary.GetBasket().PurchaseOrder.BillingAddress is always null? My Razor code is:

    string firstName = inputFirstName.Value;

                string lastName = inputLastName.Value;

                string email = inputEmail.Value;

                string phone = inputPhone.Value;

                string mobile = inputMobile.Value;

                string zip = inputZip.Value;

                string city = inputTown.Value;

                string company = inputHouse.Value;

                string address1 = inputAddress1.Value;

                string address2 = inputAddress2.Value;

                ////get a membertype by its alias

                var mt = umbraco.cms.businesslogic.member.MemberType.GetByAlias(MemberTypeAlias); //needs to be an existing membertype            

                ////get the user(0)

                var user = new umbraco.BusinessLogic.User(0);

                ////create a new member with Member.MakeNew

                var member = umbraco.cms.businesslogic.member.Member.MakeNew(string.Format("{0} {1}", inputFirstName.Value, inputLastName.Value), inputEmail.Value, mt, user);

               ////password and loginname

                member.Password = inputPassword.Value;

                member.LoginName = inputEmail.Value;

                ////asssign a group, get the group by name, and assign its Id

                var group = umbraco.cms.businesslogic.member.MemberGroup.GetByName(MemberGroupName); //needs to be an existing MemberGroup

                member.AddGroup(group.Id);

                ////generate the member xml with .XmlGenerate

                member.XmlGenerate(new System.Xml.XmlDocument());

                ////add the member to the website cache to log the member in

                umbraco.cms.businesslogic.member.Member.AddMemberToCache(member);

     

                int countryId = int.TryParse(ddlCounry.SelectedValue, out countryId) ? countryId : 0;

                Country country = Country.Get(countryId);

                if (TransactionLibrary.HasBasket())

               {                

                    var basketPurchaseOrder = UCommerce.Runtime.SiteContext.Current.OrderContext.GetBasket().PurchaseOrder;

                    var address = basketPurchaseOrder.BillingAddress ?? new OrderAddress();

                    address.AddressName = "Billing";

                    address.FirstName = firstName;

                    address.LastName = lastName;

                    address.EmailAddress = email;

                    address.PhoneNumber = phone;

                    address.MobilePhoneNumber = mobile;

                    address.CompanyName = company;

                    address.Line1 = address1;

                    address.Line2 = address2;

                    address.PostalCode = zip;

                    address.City = city;

                    address.State = "";

                    address.Country = country;// Country.FirstOrDefault(x => x.Name == "Great Britain");

                    address.PurchaseOrder = basketPurchaseOrder;

                    Customer customer = Customer.Create(address);

                    basketPurchaseOrder.Customer = customer;

                    basketPurchaseOrder.BillingAddress = address;

                    basketPurchaseOrder.Save(); // Saves cascade to children, so the address is saved as well                

                }                           

                    var availableBillingMethods = TransactionLibrary.GetPaymentMethods(country);

                    PaymentMethod paymentMethod = availableBillingMethods != null ? availableBillingMethods.FirstOrDefault() : null;

                    if (paymentMethod != null)

                    {

                        TransactionLibrary.CreatePayment(paymentMethod.Id, requestPayment: false);                     TransactionLibrary.ExecuteBasketPipeline();

                   }                

                    var currentLanguage = System.Globalization.CultureInfo.CurrentUICulture.TwoLetterISOLanguageName.ToLower();

                    Response.Redirect(string.Format("/{0}/shop/preview", currentLanguage));

     

  • Ivan Saric 40 posts 89 karma points
    Feb 26, 2014 @ 13:34
    Ivan Saric
    0

    Also after this I loose all TransactionLibrary.GetBasket().PurchaseOrder.OrderLines. All products in basket are gone.

  • Ivan Saric 40 posts 89 karma points
    Mar 03, 2014 @ 12:30
    Ivan Saric
    0

     I found a problem.Overridden GetBasket method. Fixed this.

Please Sign in or register to post replies

Write your reply to:

Draft