+1-888-365-2779
Try Now
More in this section

Forums / Ecommerce / Order Total Incorrect

Order Total Incorrect

2 posts, 1 answered
  1. Geoffrey
    Geoffrey avatar
    24 posts
    Registered:
    05 Nov 2014
    19 Aug 2015
    Link to this post

    I am in the process of building a custom checkout widget.  I am running into two large issues.  As part of the build we are integrating the checkout widget with Avalara for calculating the tax.

    The main problem that I am having is that when I add the shipping and tax amounts to the order the Order Total is not updating.  With the tax the problem is even worse because the amount is not being saved to the database.

    Code snippet that  encapsulates what I am doing:

     cart.ShippingServiceCode = shippingMethod.ServiceCode;
    cart.ShippingServiceName = shippingMethod.ServiceName;
    cart.ShippingTotal = shippingMethod.ServicePrice.GetValueOrDefault(0);
    cart.Tax = 30; <--tax hard coded in this example.  amount really comes from avalara
    this.OrdersManager.SaveChanges();
    cart = CartHelper.GetCartOrder(this.OrdersManager, this.GetShoppingCartId());

    LiteralSubTotal.Text = order.SubTotalDisplay.ToString("C");
    LiteralOrderTotal.Text = order.Total.ToString("C"); 
    LiteralOrderDiscount.Text = order.Discounts.Sum(p => p.DiscountAmount).ToString("C");
    LiteralOrderShipping.Text = order.ShippingTotal.ToString("C");
    LiteralOrderTax.Text = order.Tax.ToString("C");

     

    The problem is that the order total does not include the shipping and the tax.  Worse is the fact that the tax amount is not saved to the database.

     I hope I am missing something obvious.

  2. Geoffrey
    Geoffrey avatar
    24 posts
    Registered:
    05 Nov 2014
    27 Aug 2015
    Link to this post

    This line ended up solving my problem:

    Telerik.Sitefinity.Abstractions.ObjectFactory.Resolve<IOrderCalculator>().CalculateAndSaveChanges(cart);

     

    Disappointing how difficult it was to figure this out.

    Answered
2 posts, 1 answered