We would like to add a new line item to a basket (instead of using CartHelper.AddEntry, which would just append the quantity if the entry is already in the cart). However this seems to be a very "manual" process, the CartHelper.CreateLineItem method is private, so we would have to rewrite this method, then manually set PlacedPrice, Quantity, Code, Name/Display Name etc.
Is there something I'm missing? It just seems odd having to rewrite code already in the EPi dlls. Is there a flag or something I can pass to AddEntry which will do this?
The project which contains CartHelper (Mediachase.Commerce.Website) is open-source and you can modify it your self http://world.episerver.com/download/Items/EPiServer-Commerce/episerver-commerce-9-tools-and-code-samples/
I am not sure about question but if I am correct in understanding you can use one of those
public virtual LineItem AddEntry(Entry entry);
public virtual LineItem AddEntry(Entry entry, bool fixedQuantity);
public virtual LineItem AddEntry(Entry entry, params CartHelper helpersToRemove);
public virtual LineItem AddEntry(Entry entry, bool fixedQuantity, params CartHelper helpersToRemove); public virtual LineItem AddEntry(Entry entry, decimal quantity, bool fixedQuantity, string warehouseCode, params CartHelper helpersToRemove);
a line item can also be added in OrderForm.LineItemCollection I guess
CartHelper.AddEntry will wrap up the items by default. Unfortunately there is no flag to control this, but you can re-implement the relevant methods in CartHelper (as they are private). From what I've heard there will eventually be a surgery on CartHelper since it's not a very helpful (or extendable) class.
Also check Quan's answer in other topic: http://world.episerver.com/forum/developer-forum/Episerver-Commerce/Thread-Container/2016/3/several-rows-in-tha-cart-for-same-variant/
I used Quan's code in the link above, worked perfect.