Order addresses are useful when you manage address data retrieved from Customer Management and Order Management, since they use different models for storing data: one uses Meta Data Plus, and the other uses Business Foundation (BF).
Classes in this topic are available in the following namespaces:
Key classes and files
- OrderAddress*. Contains properties of an address for an order.
- CustomerAddress**. Contains properties of an address for a customer.
- OrderGroup*. Contains the collection of order addresses.
- Cart*. Inherits from OrderGroup. PurchaseOrder*- inherits from OrderGroup.
- StoreHelper. Contains helper methods for converting addresses.
- CustomerProfile. Contains customer profile information, like preferred shipping and billing addresses.
- CustomerProfileWrapper. Extends and adds functionality to CustomerProfile class.
- CustomerContact**. Contains properties of contacts, like addresses, credit cards, and associated organizations.
- AddressEditModule.ascx. (CMSSite/Templates/Everything/BusinessControls/CheckoutControls/SharedModules), used in checkout by the CheckoutAddressModule.ascx (inside of CheckoutWizardModule.ascx) to create an OrderAddress.
* Metaclass from Meta Data Plus; ** BF class
How it works
- The OrderGroup.OrderAddresses property stores addresses for an order.
- This property contains an OrderAddressCollection, which contains OrderAddress instances.
- Use the OrderAddress Name property as an identifier of each address.
- Distinguish shipping and billing addresses by having different Name values.
- Addresses for a customer are stored in a similar fashion.
- The CustomerContact object for a user contains a ContactAddresses collection, which contains CustomerAddress instances.
- The CustomerContact for a user is accessible via CustomerContext.Current.GetContactForUser().
- The CustomerAddress class contains similar properties to the OrderAddress class and uses the Name property as identifiers for addresses.
- The CustomerProfileWrapper (which object for a user (accessible through SecurityContext.Current.CurrentUserProfile), contains two properties, PreferredBillingAddress and PreferredShippingAddress, which contain the name of the appropriate address.
- You can convert an OrderAddress to a ContactAddress using StoreHelper.ConvertToCustomerAddress(). You can do the opposite address conversion with the ConvertToOrderAddress() method.
Examples
Example: retrieving a customer's preferred shipping address
C#
CustomerContact contact = CustomerContext.Current.GetContactForUser(SecurityContext.Current.CurrentUser);
CustomerProfileWrapper customerProfile = SecurityContext.Current.CurrentUserProfile as CustomerProfileWrapper;
IEnumerable addresses = contact.ContactAddresses;
foreach (CustomerAddress ca in addresses)
{
if (ca.Name == customerProfile.PreferredShippingAddress)
{
//we have the preferred shipping address
}
}
Example: retrieving a shipping address
C#
string shippingAddressName = cart.OrderForms[0].Shipments[0].ShippingAddressId;OrderAddressCollection addresses = cart.OrderAddresses;
foreach (OrderAddress oa in addresses)
{
if (oa.Name == shippingAddressName)
{
//we have found the shipping address
}
}
Do you find this information helpful? Please log in to provide feedback.