Error after migrating from anonymous's cart that contains gift item

Found in

EPiServer.Commerce 9.18.0

Fixed in

EPiServer.Commerce 9.19.0

Created

Jun 30, 2016

Updated

Jul 06, 2016

Area

Core

State

Closed, Fixed and tested


Description

Create a Discount "Get gift item: Buy 1000 get, item A"

  1. Go to Sample site without logging in (anonymous user).
  2. Add items to the cart to satisfy the above discount.
    --> see that item A is added as a gift item.
  3. Log in by any user.
  4. View the cart.

Expected: You see item A in the cart.
Actual: Error

"Page could not be loaded
The link you specified does not work. This may either be the result of temporary maintenance or an incorrect link."

Detailed error information (authorized by permissions to functions)

Error occured
6/30/2016 1:52:58 PM

User IP
172.16.20.233

User Agent
Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36

Url
http://vnlabvm01:17002/en/Standard-Cart/

Referer
http://vnlabvm01:17002/

ArgumentOutOfRange_Index
Parameter name: index
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentOutOfRangeException: ArgumentOutOfRange_Index
Parameter name: index

Source Error:

Line 96: if (IsVNextEnabled())
Line 97: {
Line 98: CartHelper.MergeShipments(form);
Line 99: CartHelper.ClearShippingInfo(form);
Line 100: CartHelper.Cart.AcceptChanges();

Source File: c:\EPiServer\7.5Sample_Front_17002\wwwroot\Templates\Sample\Units\CartCheckout\CartSimpleModule.ascx.cs Line: 98

Stack Trace:

[ArgumentOutOfRangeException: ArgumentOutOfRange_Index
Parameter name: index]
Mediachase.Commerce.Storage.StorageCollectionBase.System.Collections.IList.get_Item(Int32 index) +275
Mediachase.Commerce.Storage.MetaStorageCollectionBase`1.get_Item(Int32 index) +32
Mediachase.Commerce.Website.Helpers.CartHelper.MergeShipments(OrderForm form) +240
EPiServer.Commerce.Sample.Templates.Sample.Units.CartCheckout.CartSimpleModule.BindData() in c:\EPiServer\7.5Sample_Front_17002\wwwroot\Templates\Sample\Units\CartCheckout\CartSimpleModule.ascx.cs:98
EPiServer.Commerce.Sample.Templates.Sample.Units.CartCheckout.CartSimpleModule.Page_Load(Object sender, EventArgs e) in c:\EPiServer\7.5Sample_Front_17002\wwwroot\Templates\Sample\Units\CartCheckout\CartSimpleModule.ascx.cs:33
System.Web.UI.Control.LoadRecursive() +71
System.Web.UI.Control.LoadRecursive() +190
System.Web.UI.Control.LoadRecursive() +190
System.Web.UI.Control.LoadRecursive() +190
System.Web.UI.Control.LoadRecursive() +190
System.Web.UI.Control.LoadRecursive() +190
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3178