Ok, if I add
in the last step it works. Is that the way to do it? Feels a little Mediachase old school :)
I might be missing something, but the general advice is to not have to cast back to the concrete implementations. For example I'm not sure why this is needed:
((OrderForm)returnOrderForm).Total = order.GetFirstForm().GetTotal(order.Market, order.Currency).Amount; ((OrderForm)returnOrderForm).DiscountAmount = 0; ((OrderForm)returnOrderForm).ShippingTotal = 0;
Also this might not be correct (your might mean returnLineItem.Quantity?)
lineItem.ReturnQuantity = lineItem.Quantity;
The code is taken from the article I linked to and from reflecting the code used in the commerce manager. Without the lines of code (more correct and not "test" code as I posted above) all totals will be 0 on the returns tab in Commerce Manager. Do you have an example code that just creates a return for one line item in the way it should look?
The part of creating the return order form is OK (although I'd recommend to use constructor injection instead of servicelocator ). The part of casting back to OrderForm is not OK IMO. I can't look it up now (on vacation actually), but there should be APIs to validate and calculate the total and such.
EPiServer CMS: 11.3.3
EPiServer Commerce: 11.8.1
I'm trying to create a return on an order and have found this, https://world.episerver.com/documentation/developer-guides/commerce/orders/using-the-return-order-form/, but it only shows every step in isolation and I can't seem to get them to work together. I can create the return form but line items are not included. The code I have tried with is the following,
But like I said it only creates the return but without any line items. Any pointers to what I'm missing?