Try our conversational search powered by Generative AI!

Issue with merging cart after login if SKU already exists in users cart.


Hi All,

I am running into a weird issue that happens when you add line items to your cart while not being logged in. If the items exist in your logged in cart, they don't get merged with the non-logged in line items, a separate line item is created. Wondering if this is a known bug and if there is a work around? Below is a screen shot of a cart where this is happening. 

Episerver Commerce Cart Bug

Here are the versions of Episerver I am running:


Any help is greatly appreciated. 



Jun 27, 2017 23:55

No, this is not a known bug. I also tested on our latest Quicksilver and everything is fine. How do you add the item to the cart? 

Jun 28, 2017 9:55

Hi Quan,

Here is my function to add item to cart:

private CartActionResult AddToCart(string name, LineItem lineItem)
            CartHelper ch = new CartHelper(name);
            string messages = string.Empty;

            if (lineItem.Quantity < 1)
                lineItem.Quantity = 1;

            // Need entry for adding to cart
            var entry = CatalogContext.Current.GetCatalogEntry(lineItem.Code);
            ch.AddEntry(entry, lineItem.Quantity, false, new CartHelper[] { });

            // Need content for easier access to more information
            ContentReference itemLink = _referenceConverter.GetContentLink(entry.CatalogEntryId,
                CatalogContentType.CatalogEntry, 0);
            EntryContentBase entryContent = _contentLoader.Get<EntryContentBase>(itemLink);

            if (string.IsNullOrEmpty(lineItem.ImageUrl))
                lineItem.ImageUrl = entryContent.GetDefaultImage();

            if (string.IsNullOrEmpty(lineItem.ArticleNumber))
                lineItem.ArticleNumber = entry.ID;

            lineItem.Name = TryGetDisplayName(entry);

            messages = RunWorkflowAndReturnFormattedMessage(ch.Cart, OrderGroupWorkflowManager.CartValidateWorkflowName);

            return new CartActionResult() { Success = true, Message = messages };



Jun 28, 2017 16:06

While I can't explain why that happens - you can workaround by override the cart merging process and take the control yourself:

I can't reproduce the problem on our WebForm sample site, which is using CartHelper like yours.

Jun 28, 2017 16:22

Hi John,

Does your site use VNext feature? Is there any shipment in your cart?

Jun 29, 2017 10:41

Hi Bien,

No on both accounts. 


Jun 29, 2017 16:29

Ok, I think I found where's the issue and will file a bug for that. A workaround could be:

  • Enable VNext feature


  • when adding item to cart, also add that item to a shipment in the cart as well, create a shipment for cart if no shipment exists.


Jun 30, 2017 8:08

Heck yeah, thanks Bien!


Jun 30, 2017 18:27

This fix was released as part of Commerce 11.1.0 - see

Edited, Aug 16, 2017 16:19
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.