This content is archived. See latest version here

Order addresses are useful when managing address data retrieved from Customer Management and Order Management, since these use different models for storing data, where one uses Meta Data Plus and the other Business Foundation.

Classes referred to here are available in the following namespaces:

Key classes and files

  • OrderAddress* - contains the properties of an address for an order.
  • CustomerAddress**- contains the 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 profile information about a customer, like preferred shipping and billing addresses.
  • CustomerProfileWrapper - extends and adds functionality to CustomerProfile class.
  • CustomerContact** - contains properties of contacts like addresses, credit cards, 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; ** Business Foundation class

How it works

  • Addresses for an order are stored in the OrderGroup.OrderAddresses property. This property contains anOrderAddressCollection, which containsOrderAddress instances. The OrderAddress Name property is used as an identifier of each address. Shipping and billing addresses are distinguished by having different Name values.
  • Addresses for a customer are stored in a similar fashion. TheCustomerContact object for a user contains aContactAddresses collection, which containsCustomerAddress instances. The CustomerContact for a user is accessible via CustomerContext.Current.GetContactForUser().TheCustomerAddress 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 andPreferredShippingAddress, which contain the name of the appropriate address.
  • An OrderAddress can be converted to a ContactAddress using StoreHelper.ConvertToCustomerAddress(); the opposite address conversion can be done with theConvertToOrderAddress() method.


Example: retrieving the preferred shipping address for a customer

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

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

Last updated: Mar 31, 2014