Order Total Incorrect

Posted by Community Admin on 05-Aug-2018 18:26

Order Total Incorrect

All Replies

Posted by Community Admin on 19-Aug-2015 00:00

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.

Posted by Community Admin on 27-Aug-2015 00:00

This line ended up solving my problem:

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

 

Disappointing how difficult it was to figure this out.

This thread is closed