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, Spring MVC controllers are 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.
- ShippingAddressFormControllerImpl - Spring MVC controller that allows users to select or create a shipping address during the checkout process.
- BillingAddressFormControllerImpl - Spring MVC controller that allows users to select or create a billing address during the checkout process.
- AddressFormControllerImpl - Used to update and create new addresses in the customer self-service area. The billing and shipping address form controllers delegate to this controller when the user wishes to update an existing address.
- checkoutAddress.vm - Velocity template for inputing a shipping or billing address during the checkout process
- address/create.vm - Velocity template for creating or editing an address in the customer self-service area
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.