Elastic Path Commerce Development

Shipping and Billing Addresses

Shipping and Billing Addresses

The Customer object contains a collection of addresses entered by a particular user. These addresses can be added to the collection in the customer self-service area or during a checkout. The collection contains addresses used for shipping as well as for billing and does not distinguish between them. A customer can have a single preferred shipping address and a single preferred billing address. These preferences are stored as references to addresses in the customer object's address collection.

During the checkout process, the front end is responsible for prompting the customer to create and/or select the address to use for the checkout in progress. The shopping cart maintains references to the selected shipping and billing addresses to be used in the order.

Key classes and files

  • Address - Interface implemented by all address classes.
  • Customer - Maintains a collection of a user's addresses, including a reference to the preferred shipping and billing addresses.
  • ShoppingCart - Maintains a reference to the billing and shipping addresses a customer has selected for a particular checkout.
  • AbstractAddressImpl - Abstract implementation of the Address interface
  • CustomerAddressImpl - Subclass of AbstractAddressImpl used to represent a customer's addresses. There are no members in this class; it is required to enable the persistence engine to store these addresses in a separate table from order addresses.
  • OrderAddressImpl - Subclass of AbstractAddressImpl used to represent addresses associated with orders. There are no members in this class; it is required to enable the persistence engine to store these addresses in a separate table from customer addresses.

Implementation details

  • Although any address can be selected as a shipping or billing address, addresses used as shipping addresses during checkout are validated by checking whether a shipping service level covering that region exists.
  • During the final checkout, a copy of the CustomerAddress is made and associated with the order. This prevents the loss of the address information if the customer modifies or deletes the address.