Try our conversational search powered by Generative AI!

Using ReturnForm with discount and returning 1 of 3 items



We are using the code below to create a return for an order with discount. I am not sure what to expect in this case, but the result is strange. It seems that the discount is not recalculated and that gives strange values for the returnlineitem. After executing the code below the ReturnLineItem in ReturnsForms will still have the same value for OrderLevelDiscountAmount. I expected this to be lowered when one item was removed. I tried using ApplyDiscounts (with ReevaluatePromotions = true), but that makes no difference. The documentation I found for this is not very clear. Can someone point me to a working example for this scenario? And what should I expect as ExtendedPrice for a ReturnLineItem using IReturnLineItemCalculator?

var purchaseOrderFactory = ServiceLocator.Current.GetInstance<IPurchaseOrderFactory>();
var returnOrderForm = purchaseOrderFactory.CreateReturnOrderForm(order);

var shipment = order.GetFirstShipment();
var returnShipment = purchaseOrderFactory.CreateReturnShipment(shipment);

// originalLineItem.Quantity = 3 and discount = 10%
var returnLineItem = _purchaseOrderFactory.CreateReturnLineItem(originalLineItem, 1,   
    "Some reason");

_returnOrderService.CompleteReturn(order, returnForm);



Episerver Commerce 13.32.1, CMS 11.20.11

Feb 03, 2023 16:49

The calculations made by DefaultReturnLineItemCalculator doesn't make sense as far as I can se. At least not for my case. I ended up implementing my own version instead.

Feb 06, 2023 13:29
* 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.