Copied to clipboard

Flag this post as spam?

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

  • Puck Holshuijsen 91 posts 354 karma points
    Oct 05, 2017 @ 06:18
    Puck Holshuijsen

    SaveBillToAddress doesn't actually save the Billing address inside checkoutmanager in custom checkout

    Hi Guys,

    I am having this really weird issue, which I can't figure out what is going wrong.

    I am creating a (almost) one page checkout, but for some reason the SaveBillToAddress puts an empty object inside it. Also the Shipping Address is really set after I call the SaveShipmentRateQuote.

    This is the value inside the CheckoutManager > Customer > ExtendedData

    [2] = {[merchBillingAddress, <Address i:nil="true" xmlns:i="" xmlns="" />]}

    The same thing for the SaveShippingAddress, but after calling the SaveShipmentRateQuote, it is transformed to a real address object.

    This is my full code:

    protected virtual ActionResult HandleCheckoutStep2SaveSuccess(TCheckoutModel model)
            string redirectUrl = model.successRedirectUrl;
            model.basket = CurrentCustomer.Basket();
            model.customer = (ICustomer)CurrentCustomer;
            model.customerBillingAddressess = model.customer.Addresses.Where(x => x.AddressType == AddressType.Billing).ToList();
            model.customerShippingAddressess = model.customer.Addresses.Where(x => x.AddressType == AddressType.Shipping).ToList();
            var billingAddress = model.customerBillingAddressess.FirstOrDefault(x => x.Key == model.customerBillingAddressKey);
            var shippingAddress = model.customerShippingAddressess.FirstOrDefault(x => x.Key == model.customerShippingAddressKey);
            var tmpShippingAddress = ShippingAddressFactory.Create(model.customer, shippingAddress);
            model.shippingMethods = getShipments(Basket, tmpShippingAddress);
            var selectedShippingMethod = model.shippingMethods.ProviderQuotes.FirstOrDefault(x => x.ShipMethod.Key == model.shippingMethodKey);
            model.paymentMethods = getPayments();
            var selectedPaymentMethod = model.paymentMethods.PaymentGatewayMethods.FirstOrDefault(x => x.PaymentMethod.Key == model.paymentMethodKey);
            var checkoutManager = model.basket.GetCheckoutManager();
            checkoutManager.Customer.SaveBillToAddress(BillingAddressFactory.Create(billingAddress.AsAddress(string.Format("{0} {1}", model.customer.FirstName, model.customer.LastName))));
            checkoutManager.Customer.SaveShipToAddress(ShippingAddressFactory.Create(shippingAddress.AsAddress(string.Format("{0} {1}", model.customer.FirstName, model.customer.LastName))));
            bool test = checkoutManager.Payment.IsReadyToInvoice();
            return !redirectUrl.IsNullOrWhiteSpace() ?
                Redirect(redirectUrl) :

    At first I thought my billingAddress variable was empty, but this is not the case.

    I am hoping anyone can help me with this, because I am stuck right now :(



  • Puck Holshuijsen 91 posts 354 karma points
    Oct 05, 2017 @ 09:47
    Puck Holshuijsen

    Okay, just found it out myself!

    BillingAddressFactory.Create screwed it up for me. I was passing an iAddress object in the create function, which turned it into the wrong object.

    I'm an idiot.

Please Sign in or register to post replies

Write your reply to: