Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Mark V 28 posts 158 karma points
    May 22, 2020 @ 13:51
    Mark V
    0

    Null Reference Error when trying to add a product to order

    I've taken code from the example site and applied it in mine but keep getting this error whenever I try to add an item to the cart.

    enter image description here

    I've tweaked the code to have a hardcoded product just to test the snippet but it's still in a surface controller. The weird part is that the code works when I debug, add a break point on the erroring line and inspect order. After that the code works fine, it adds the product and creates the order no problem.

      at Vendr.Core.Calculators.OrderLineCalculator.CalculateOrderLineUnitPrice(OrderReadOnly order, OrderLineReadOnly orderLine, Guid currencyId, TaxRate taxRate)
      at Vendr.Core.Pipelines.OrderLine.Tasks.CalculateOrderLineUnitPriceWithoutDiscountsTask.Execute(OrderLineCalculationPipelineArgs args)
      at Vendr.Core.Pipelines.PipelineTaskWithTypedArgsBase`2.Execute(PipelineArgs`1 args)
      at Vendr.Core.Pipelines.PipelineTaskBase`2.Execute(PipelineArgs input)
      at Vendr.Core.Pipelines.InProcPipelineInvoker.<Vendr.Core.Pipelines.IPipelineInvoker.Invoke>g__next|2_0(PipelineArgs e, <>c__DisplayClass2_0& )
      at Vendr.Core.Pipelines.InProcPipelineInvoker.<Vendr.Core.Pipelines.IPipelineInvoker.Invoke>g__next|2_0(PipelineArgs e, <>c__DisplayClass2_0& )
      at Vendr.Core.Pipelines.InProcPipelineInvoker.Vendr.Core.Pipelines.IPipelineInvoker.Invoke(IEnumerable`1 pipelineTasks, PipelineArgs args)
      at Vendr.Core.Pipelines.Pipeline.Invoke[TPipeline,TArgs,TEntity](Func`2 argsFactory)
      at Vendr.Core.Pipelines.Order.Tasks.OrderLinesCalculationPipelineTaskBase`1.Execute(OrderCalculationPipelineArgs args)
      at Vendr.Core.Pipelines.PipelineTaskWithTypedArgsBase`2.Execute(PipelineArgs`1 args)
      at Vendr.Core.Pipelines.PipelineTaskBase`2.Execute(PipelineArgs input)
      at Vendr.Core.Pipelines.InProcPipelineInvoker.<Vendr.Core.Pipelines.IPipelineInvoker.Invoke>g__next|2_0(PipelineArgs e, <>c__DisplayClass2_0& )
      at Vendr.Core.Pipelines.InProcPipelineInvoker.Vendr.Core.Pipelines.IPipelineInvoker.Invoke(IEnumerable`1 pipelineTasks, PipelineArgs args)
      at Vendr.Core.Pipelines.Pipeline.Invoke[TPipeline,TArgs,TEntity](Func`2 argsFactory)
      at Vendr.Core.Pipelines.SubPipelineTaskBase`2.Execute(PipelineArgs`1 input)
      at Vendr.Core.Pipelines.PipelineTaskBase`2.Execute(PipelineArgs input)
      at Vendr.Core.Pipelines.InProcPipelineInvoker.<Vendr.Core.Pipelines.IPipelineInvoker.Invoke>g__next|2_0(PipelineArgs e, <>c__DisplayClass2_0& )
      at Vendr.Core.Pipelines.InProcPipelineInvoker.<Vendr.Core.Pipelines.IPipelineInvoker.Invoke>g__next|2_0(PipelineArgs e, <>c__DisplayClass2_0& )
      at Vendr.Core.Pipelines.InProcPipelineInvoker.<Vendr.Core.Pipelines.IPipelineInvoker.Invoke>g__next|2_0(PipelineArgs e, <>c__DisplayClass2_0& )
      at Vendr.Core.Pipelines.InProcPipelineInvoker.Vendr.Core.Pipelines.IPipelineInvoker.Invoke(IEnumerable`1 pipelineTasks, PipelineArgs args)
      at Vendr.Core.Pipelines.Pipeline.Invoke[TPipeline,TArgs,TEntity](Func`2 argsFactory)
      at Vendr.Core.Calculators.OrderCalculator.CalculateOrder(OrderReadOnly order)
      at Vendr.Core.Models.Order.Recalculate(Boolean force, IOrderCalculator orderCalculator)
      at Vendr.Core.Models.Order.Recalculate(IOrderCalculator orderCalculator)
      at Vendr.Core.OrderExtensions.Recalculate(Order order)
      at Vendr.Core.Services.OrderService.SaveOrder(Order entity)
      at MyCoolSite.Core.Controllers.Surface.CartSurfaceController.AddToCart(String productReference) in C:\Sites\MyCoolSite\MyCoolSite\MyCoolSite.Core\Controllers\Surface\CartSurfaceController.cs:line 49
      at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
      at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c.<BeginInvokeSynchronousActionMethod>b__9_0(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
      at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
      at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
      at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass11_0.<InvokeActionMethodFilterAsynchronouslyRecursive>b__0()
      at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass11_2.<InvokeActionMethodFilterAsynchronouslyRecursive>b__2()
    
  • Matt Brailsford 4125 posts 22224 karma points MVP 9x c-trib
    May 22, 2020 @ 14:44
    Matt Brailsford
    0

    Hi Mark,

    What version of Vendr are you using?

    /Matt

  • Mark V 28 posts 158 karma points
    May 22, 2020 @ 14:47
    Mark V
    0

    Hey Matt,

    At the time of writing it was 1.1.3 but I've just updated to 1.1.4 and seeing the same results

  • Matt Brailsford 4125 posts 22224 karma points MVP 9x c-trib
    May 22, 2020 @ 14:53
    Matt Brailsford
    100

    Hmm, do you have a price defined on your product for the orders given currency?

  • Mark V 28 posts 158 karma points
    May 22, 2020 @ 15:06
    Mark V
    0

    That was it!

    I was playing around and ended up deleting and creating a few new stores and seems changing the store resets the prices. I knew I had something similar working yesterday.

    Thank you very much

  • Matt Brailsford 4125 posts 22224 karma points MVP 9x c-trib
    May 22, 2020 @ 15:15
    Matt Brailsford
    1

    No problem.

    I'll still go add it as a bug on our issue tracker as we ultimately have some code that isn't performing a null check.

    Thanks for reporting it and glad we could get you working 👍

    /Matt

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies