By default, all items are allowed to go into any type of ShippingGroup. However, it might be necessary to prevent specific commerce items from being added to certain types of shipping groups. For example, only certain types of items can be assigned to an ElectronicShippingGroup. It does not make sense for a box of golf balls to be shipped electronically.
Follow these steps to prevent commerce items from being added to specific types of shipping groups:
Add a new
shippingGroupsAllowedproperty to the SKU item descriptor in the product repository. TheshippingGroupsAllowedproperty should contain a list of shipping groups to which the SKU that thisCommerceItemrepresents can be added.Note: The available
ShippingGrouptypes are listed in theshippingTypeClassMapproperty of theOrderToolscomponent.Override any necessary methods to make sure the
shippingGroupsAllowedproperty in the SKU that thisCommerceItemrepresents matches theshippingGroupClassTypeproperty of theShippingGroupto which theCommerceItemis being added.These methods are
addItemToShippingGroup()in theShippingGroupManager, andaddItemQuantityToShippingGroupandaddRemainingItemQuantityToShippingGroup()in theCommerceItemManager.
Alternatively, you could create a shippingGroupsNotAllowed property for the SKU item descriptor in the product repository. In this property, list the names of the ShippingGroup types to which a CommerceItem is not allowed.

