diff --git a/VirtoCommerce.Storefront/Domain/Cart/Demo/DemoCartBuilder.cs b/VirtoCommerce.Storefront/Domain/Cart/Demo/DemoCartBuilder.cs index d3096848..c1cf3e7a 100644 --- a/VirtoCommerce.Storefront/Domain/Cart/Demo/DemoCartBuilder.cs +++ b/VirtoCommerce.Storefront/Domain/Cart/Demo/DemoCartBuilder.cs @@ -128,12 +128,17 @@ public override async Task MergeWithCartAsync(ShoppingCart cart) { var newGroup = new ConfiguredGroup(group.Quantity, group.Currency, group.ProductId); Cart.ConfiguredGroups.Add(newGroup); + foreach (var item in group.Items) { - var newItem = item.Clone() as LineItem; + var newItem = (LineItem)item.Clone(); newItem.ConfiguredGroupId = newGroup.Id; var existingLineItem = cart.Items.FirstOrDefault(li => li.ProductId.EqualsInvariant(newItem.ProductId)); - cart.Items.Remove(existingLineItem); + if (existingLineItem != null) + { + cart.Items.Remove(existingLineItem); + } + await AddLineItemAsync(newItem); } }