Issue with create order detail in 7.0
Hi,
I am successfully able to create an order and I am also creating an order detail for the order. In the admin I can see is only the Order and not the order details (screenshot attached). When I run the sql query to fetch the details i am able to see in the database that order details is created.
The code I am using is below. Please let me know what I am missing that is creating this issue.
private static void CreateOrderDetail(Order order, Guid productId, string title, string sku, double weight, decimal total, decimal price,
int quantity, int taxClassId, decimal taxRate, bool taxInPrice, decimal deltaPrice, decimal basePrice, bool isShippable, bool isOnSale)
OrdersManager ordersManager = OrdersManager.GetManager();
if (order == null)
return; // Order does not exist.
//Create a new OrderDetail
OrderDetail detail = ordersManager.CreateOrderDetail();
//Set properties.
detail.BasePrice = basePrice;
detail.CreatedDate = DateTime.Now;
detail.DeltaPrice = deltaPrice;
detail.IsOnSale = isOnSale;
detail.IsShippable = isShippable;
detail.Price = price;
detail.ProductId = productId;
detail.Quantity = quantity;
detail.Sku = sku;
// detail.TaxClassId = taxClassId;
detail.TaxInPrice = taxInPrice;
detail.TaxRate = taxRate;
detail.Title = title;
detail.Total = total;
detail.Weight = weight;
//Associate detail with order.
detail.Parent = order;
order.Details.Add(detail);
ordersManager.SaveChanges();
Hi Praneeth,
I have attached a code sample for full checkout through code, where all order details are set, in addition to the other options and settings for the checkout. I think it will be useful for you to review the whole process and the CartDetail information configuration for the Order. Please, check the product and customer to match the ones you need. You can also check this documentation article.
Regards,
Nikola Zagorchev
Telerik
Thanks a lot. It helps a lot.
Regards
Praneeth
Hi
I am glad the provided code has helped you. Write back if you need further assistance.
Regards,
Nikola Zagorchev
Telerik