Developer forum

Forum » Development » Error in setting Price to orderline

Error in setting Price to orderline

Umar Farooq
Reply

Hi,

I have a service to add products to cart and we are using price module for product prices. I am adding orderlines like this 

var builderConfig = new OrderLineBuilderConfig { ProductId = product.ProductID, Quantity = double.Parse(product.Quantity), UnitId = "", AddToCart = true, };
OrderLine ol = orderLineService.OrderLineBuilder(order, builderConfig);

orderLineService.Save(ol);

 

and getting the following error. DW version 9.5.6

<Error>
<Message>An error has occurred.</Message>
<ExceptionMessage>
Object reference not set to an instance of an object.
</ExceptionMessage>
<ExceptionType>System.NullReferenceException</ExceptionType>
<StackTrace>
at Dynamicweb.Ecommerce.Prices.PriceInfo.Add(IPriceInfo info) at Dynamicweb.Ecommerce.Prices.PriceInfo.Add(IPriceReferenceInfo info) at Dynamicweb.Ecommerce.Orders.OrderLine.get_UnitPrice() at Dynamicweb.Ecommerce.Orders.OrderLine.get_Price() at Dynamicweb.Ecommerce.Orders.OrderLineRepository.Save(OrderLine orderline, DataRow dataRow) at Dynamicweb.Ecommerce.Orders.OrderLineRepository.Save(OrderLine orderLine) at Dynamicweb.Ecommerce.Orders.OrderLineService.Save(OrderLine orderLine) at Controllers.WebApi.designerController.Dealer(RecievedData Data) in C:\Solutions\Website\Controllers\WebApi\designerController.cs:line 199 at lambda_method(Closure , Object , Object[] ) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()
</StackTrace>
</Error>
 

Replies

 
Nicolai Pedersen
Reply

I think the orderline is missing a currency - and it cannot be retrieved from the context because you are in the webapi.

You can download the debugging symbols from the nuget feed and attach a debugger to see where it fails...

Sorry about the inconvenience, Nicolai

 

You must be logged in to post in the forum