Show Address on Check Out

Hi,

I am trying to add the Address to the top of the Check Out screen in the starter site.

The code below is not working - event viewer is stating the index is out of range. The code is in the CheckOutDetail.cs in the Commerce Components.

Please Advise.

string name =String.Empty;

string firstName =this.Basket.Addresses[0].FirstName;

if (!String.IsNullOrEmpty(firstName))

{

name = firstName +" ";

}

name +=this.Basket.Addresses[0].LastName;

writer.WriteEncodedText(name);

writer.WriteBreak();

[1082 byte] By [Xcel] at [2008-1-7]
# 1
I think you need to get an OrderForm first:

string firstName = this.Basket.OrderForm[0].Addresses[0].FirstName;

-Max

MaxAkbar at 2007-10-2 > top of Msdn Tech,Commerce Server,Commerce Server 2007...
# 2

Still not working.

What I have tried doing is the following

foreach (OrderForm orderForm in this.Basket.OrderForms)

{

writer.WriteEncodedText("Test Loop 2:");

foreach (Shipment address in orderForm.Shipments)

writer.WriteEncodedText("Test Loop 3:");

I get Test Loop 2 to show however there are no Shipments ?

Please Advise.

Xcel at 2007-10-2 > top of Msdn Tech,Commerce Server,Commerce Server 2007...
# 3
Use my OrderForm Viewer to see if you have any values in Shipment.

-Max

MaxAkbar at 2007-10-2 > top of Msdn Tech,Commerce Server,Commerce Server 2007...
# 4

There are no Shipments - they must not get created until the order Closes.

So, I am now trying to retrieve the soldToAddress

string soldToAddress = this.Basket.SoldToAddressId;

//if (i==0)

//{

//i = i + 1;

writer.WriteEncodedText(this.Basket.Addresses[soldToAddress].LastName);

//OrderAddress address =

I looked at the Basket in Customer and Order Manager and I see that it populated just can't seem to get the code right to retrieve it.
Xcel at 2007-10-2 > top of Msdn Tech,Commerce Server,Commerce Server 2007...
# 5

My last response is not correct,

In Customer and Order Manager I was looking under Orders not Baskets.

The Basket has no Address Information. Apparently no Address information is Saved Shipping or Order Address with the Order until the Submit button is clicked, even though you select an Address prior to that.

So, unless I am missing something it does not look like it is possible to get address information in the CheckOutDetail.cs code file and have it populated on the Confirmation page in Commerce Server.

Please Confirm or Advise.

Xcel at 2007-10-2 > top of Msdn Tech,Commerce Server,Commerce Server 2007...
# 6
Yes, it seems that the starter site forgets your address info and only saves the data after you checkout. Looking at the code the address info can be found at shipment.ShippingAddressId.

It seems that if you labondon your cart after you have selected your address and other info and then continue at a later time the Starter Site forces you to select all the options again. There is a method this.SanitizeBasket(); under the OnLoad method that sets everything to null and allows the user to reset their values (pretty dangerous business rule ).

-Max

MaxAkbar at 2007-10-2 > top of Msdn Tech,Commerce Server,Commerce Server 2007...
# 7

Max thank you for your assistance.

Xcel at 2007-10-2 > top of Msdn Tech,Commerce Server,Commerce Server 2007...