Hi,
I have a product that is a parts list and one of the products in the list has variants. Is there a way, when adding the parts list product to the cart, to select a specific variant instead of adding the master product?
I tried adding the following code, to the add to cart button, to select the variant but it still adds the master product:
var bomProduct = Dynamicweb.Ecommerce.Services.Products.GetProductById(product?.Id, product?.VariantId, Dynamicweb.Ecommerce.Common.Context.LanguageID); if (bomProduct != null && bomProduct.Items.Any()) { foreach (var bomItem in bomProduct.Items) { if (string.IsNullOrEmpty(bomItem.BomGroupId)) { var prod = Dynamicweb.Ecommerce.Services.Products.GetProductById(bomItem.BomProductId, bomItem.BomVariantId, Dynamicweb.Ecommerce.Common.Context.LanguageID); if (prod != null) { disableAddToCart = prod.Discontinued || !prod.Active ? "disabled" : disableAddToCart; if (prod.IsVariantMaster && prod.Active) { <select class="mt-2 mb-2 pt-2 pb-2" name="@bomItem.Id"> @foreach (var variant in prod.VariantCombinations) { <option value="@variant.ProductId|@variant.VariantId">@prod.Name @variant.GetVariantName(Dynamicweb.Ecommerce.Common.Context.LanguageID).ToString()</option> } </select> } } }
DW version 9.15.14