Try our conversational search powered by Generative AI!

Exception when creating order return if applied promotion was deleted

Found in

EPiServer.Commerce 12.3.1

Fixed in

EPiServer.Commerce 12.6.0

(Or a related package)

Created

Jul 06, 2018

Updated

Aug 20, 2018

State

Closed, Fixed and tested


Description

Steps to reproduce

  1. Create [Buy products for discount from other selection] discount: Buy Mens Shoes get 20% off Mens Shoes.
  2. Anonymous user creates and completes order with one variant SKU-44477844. Discount is applied correctly.
  3. Delete the discount above.
  4. Complete the order.
  5. Create return.
  6. Click on <OK> button in <New Line Item> dialog.

Expect:
It works correctly.

Actual:
You get the exception below.

(Note: This does work correctly in Commerce 12.3.0)

Collection was modified; enumeration operation may not execute.
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.InvalidOperationException: Collection was modified; enumeration operation may not execute.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[InvalidOperationException: Collection was modified; enumeration operation may not execute.]
System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) +56
System.Collections.Generic.Enumerator.MoveNextRare() +14635326
EPiServer.Commerce.Order.Internal.ReturnOrderPromotionInvalidation.<UpdateSavedAmount>g__OnLineItemDiscount|3_2(PromotionInformation promotionBefore, PromotionInformation promotionAfter) +636
EPiServer.Commerce.Order.Internal.ReturnOrderPromotionInvalidation.UpdateSavedAmount(PromotionInformation before, PromotionInformation after) +84
EPiServer.Commerce.Order.Internal.ReturnOrderPromotionInvalidation.GetPromotionsDelta(IList`1 allPromotionsBefore, IList`1 allPromotionsAfter) +222
EPiServer.Commerce.Order.DefaultReturnOrderService.InvalidatePromotions(IPurchaseOrder purchaseOrder, IReturnOrderForm returnOrderForm) +946
Mediachase.Commerce.Manager.Apps.Order.Modules.ReturnOrderLineItemEdit.btnSave_ServerClick(Object sender, EventArgs e) +1182
System.Web.UI.HtmlControls.HtmlButton.OnServerClick(EventArgs e) +137
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5028