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
shippingGroupsAllowed
property to the SKU item descriptor in the product repository. TheshippingGroupsAllowed
property should contain a list of shipping groups to which the SKU that thisCommerceItem
represents can be added.Note: The available
ShippingGroup
types are listed in theshippingTypeClassMap
property of theOrderTools
component.Override any necessary methods to make sure the
shippingGroupsAllowed
property in the SKU that thisCommerceItem
represents matches theshippingGroupClassType
property of theShippingGroup
to which theCommerceItem
is being added.These methods are
addItemToShippingGroup()
in theShippingGroupManager
, andaddItemQuantityToShippingGroup
andaddRemainingItemQuantityToShippingGroup()
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.