Create order from code

I am upgrading Litium 7.2.2 to 8.11.2. I have a scheduled task to create order based on the values in a file.

In old version, order is creating using OrderRowCarrier as below

                    // Create a new order row carrier for each row
                    var orderRowCarrier = new OrderRowCarrier
                    {
                        ID = Guid.NewGuid(),
                        OrderID = orderCarrier.ID,
                        ArticleNumber = artilceNumber,
                        ExternalOrderRowID = orderID,
                        Comments = string.Empty,
                        VATPercentage = 0.25m,
                        Quantity = quantity,
                        UnitListPrice = decimal.Parse(orderRow.SalesPrice.Trim(), new CultureInfo("en-US")),
                    };

                   
                    if (decimal.TryParse(orderRow.Discount > 0)
                    {
                        orderRowCarrier.DiscountPercentage = (Discount / orderRowCarrier.UnitListPrice) * 100;
                    }

I found similar question in forum and it using CartContext to create new order - Create new order using code.

But i was not able to add any discount or order details (SalesOrder.Row collection in readonly). Is there any alternate way for this?

Litium version: [Litium 8.11.2]

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.