Hi Přemek,
I had a similar problem. Kentico only checks if a line item is unique based on whether it has the same SKUID and the same product options as another line item, but if the cart item's custom data is different, it doesn't care and just increments the quantity anyway. We solved it by writing a custom method to replace AddShoppingCartItem(), in order to strictly add a single quantity line item to the cart regardless of existing skuids. This site does not use product options, so it's quite simple, but if your site does use product options you'll need to work with them too and it gets a bit more complicated.
Put something like this in your CMSCustom.cs file and see how it goes!
(Maybe add some exception handling and commenting of course...)
private static ShoppingCartItemInfo AddSingleShoppingCartItem(int skuid, ShoppingCartInfo cart)
{
ShoppingCartItemInfo info = new ShoppingCartItemInfo();
info.SKUID = skuid;
info.CartItemUnits = 1;
info.CartItemParentGUID = Guid.Empty;
info.ShoppingCartID = cart.ShoppingCartID;
info.SKUObj = SKUInfoProvider.GetSKUInfo(skuid);
cart.CartItems.Add(info);
cart.ShoppingCartContentTable = null;
cart.ShoppingCartTaxTable = null;
cart.ClearShoppingCartHashtables();
return info;
}
Cheers
Andrew Thompson
Get Started