When an Order is first created, it has an empty ShippingGroup, which serves as the default ShippingGroup for the Order. The type of default ShippingGroup that is created is determined by the defaultShippingGroupType property of the OrderTools component. By default, this property is set to hardgoodShippingGroup.
When a CommerceItem is added to the Order, that item is automatically a part of the default ShippingGroup because it is assumed that when there is only one ShippingGroup, all items are a part of that group. However, once a second ShippingGroup is added to the Order, the existing CommerceItem and any new commerce items must be explicitly assigned to one of the two shipping groups; any items that were in the default ShippingGroup are no longer a part of any ShippingGroup.
Before the Order is checked out, all of the order’s commerce items must be a part a ShippingGroup. This requirement is checked during the checkout process by the validateForCheckout pipeline, which is executed by the processOrder pipeline. Each processor in the validateForCheckout pipeline validates a different part of the Order as complete. The validateShippingGroupsForCheckout processor, in specific, validates the shipping groups in the Order. The shipping groups are considered complete if the following criteria are met:
- None of the required fields (name, address, city, state, and postal code) are empty in any - ShippingGroup.
- All of the commerce items in the - Orderare assigned to a- ShippingGroup. This requirement must be met according to the following rules:- If there is only one - ShippingGroupin the- Orderand no relationships exist between that- ShippingGroupand the commerce items in the- Order, then the shipping of all commerce items in the- Orderimplicitly is accounted for by that- ShippingGroup.
- If there is only one - ShippingGroupin the- Orderand relationships exist between that- ShippingGroupand the commerce items in the- Order, or if there is more than one- ShippingGroupin the- Order, then every- CommerceItemin the- Ordermust have its shipping explicitly accounted for with one or more- ShippingGroupCommerceItemRelationshipobjects, as follows:- If a - CommerceItemhas a- ShippingGroupCommerceItemRelationshipof type- ShippingQuantityRemaining, then the item’s shipping is accounted for regardless of whether it has other shipping relationships. This is because a “remaining” relationship type covers any quantity of the- CommerceItemthat is not accounted for by other shipping relationships.- If a - CommerceItemhas one or more- ShippingGroupCommerceItemRelationshipobjects of type- ShippingQuantity, but no relationship of type- ShippingQuantityRemaining, then the total quantity of the- CommerceItemcovered by the relationships must be equal to or greater than the quantity in the- CommerceItem.- The - rangeproperty in the- ShippingGroupCommerceItemRelationshipidentifies which particular items out of the total quantity of a- CommerceItemare associated with a given- ShippingGroup.- Note: The priority of a - Relationshipin an- Order, which is determined by the relationship’s type, plays a role in when the- Relationshipis processed as the- Orderproceeds through the checkout process. For more on relationship types and priority, see the Relationship Priority subsection of the Using Relationship Objects section in the Working With Purchase Process Objects chapter.
 
For more information on ShippingGroupCommerceItemRelationship objects, see the Relationship Types section in this chapter. For more information on the processOrder and validateForCheckout pipelines, see the Checking Out an Order section of the Configuring Purchase Process Services chapter.

