Here’s a quick code snippet that shows demonstrates how to loop through the kit components assigned to a product.  This is useful when you need to manually parse out something specific from the kit setup of a particular product.

// find the product associated with a particular kit choice 

int _KitProductId = -1;

foreach (ProductKitComponent _PKC in _Product.ProductKitComponents)

{

    KitComponent _KitComp = _PKC.KitComponent;

    foreach (KitProduct _KitProd in _KitComp.KitProducts)

    {

        if (_KitProd.Quantity == 3) // any test you want to make here

        {

            _KitProductId = _KitProd.KitProductId;

            break;

        }

    }

}

 

// if we didn't find a choice in the kit list for the given product, we cannot

// add this item to the basket at this time.  

 

if (_KitProductId == -1)

{

    ErrorMessageDataSource.Insert(new ErrorMessage(MessageSeverity.Error,"CustomCode", "Could not find the product we wanted.");

    continue;

}