Adding a same item (same Code) to cart



Is it possible to add an item more than once to cart as new line. ?

example you have an item Code="xyz". and add this item to cart with a an costum field "stiching". 

lineitem 1 => code="xyz"  , stiching="Black stitches"

lineitem 2 => code="xyz"  , stiching="Dark grey stitches"

lineitem 3 => code="xyz"  , stiching="White stitches"

notice these items has same sku code.

Thanks in advance.

Feb 01, 2016 13:44

In thory yes, If you define stiching as a variant of your product and add that variant in basket. (Variants will have their unique skus, will not require to display on website.)

Feb 01, 2016 16:14

If you manually create a line item instead of using CartHelper.AddEntry then you can add the line item to OrderForm.LineItems collection which should allow you to add as long as the line item object is not exactly the same.

Feb 01, 2016 20:52

I aggree with you Mark. we needed you to add manually. CartHelper checks the lineitem code exist in order if it does exist than updates the quantity only.

This is the manually adding the item to order but this does not work some how. 

var orderForm = CartHelper.Cart.OrderForms.FirstOrDefault();
LineItem lineItem =orderForm.LineItems.FirstOrDefault(i => i.Code == product.Code);
if(lineItem !=null)
	lineItem.SetMetaField(Constants.Metadata.LineItem.RefNumber, "some value");
	lineItem.SetMetaField(Constants.Metadata.LineItem.IsConfigured, true);

	orderForm.LineItems.Add(lineItem, lineItemRollup:false);   //NOTE THIS LINE : To have two lineItems for the same SKU, set the bool LineItemRollup (second arg.) to false


Edited, Feb 03, 2016 12:17

her is the solution. this works

var orderGroup = (OrderGroup)CartHelper.Cart;

            var form = orderGroup.OrderForms.FirstOrDefault();
            var newLineItem = form.LineItems.AddNew();

            newLineItem.ParentCatalogEntryId = lineItem.ParentCatalogEntryId;
            newLineItem.Code = lineItem.Code;


Feb 05, 2016 10:21
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.