Calculate order grand total
This article explains how to calculate order grand total.
The order grand total is calculated in the pricing rules plugins. Call the following two methods to correctly calculate all the order total fields, and prepare the order to collect the payment.
using Litium.Foundation.Modules.CMS.GUI.Templates;
using System;
using Litium.Foundation.Modules;
using Litium.Foundation.Modules.ECommerce;
using Litium.Foundation.Modules.CMS;
public partial class Site_Samples_ECommerce_CheckoutCalculateOrderTotals : BaseTemplate
{
void CalculateOrderTotals()
{
//recalculate the basket.
Module<ModuleECommerce>.Instance.Orders.CalculateOrderTotals(CurrentState.Current.ShoppingCart.OrderCarrier, CurrentState.Current.Token);
//add the payment amounts to collect from user to Paymentinfo object
Module<ModuleECommerce>.Instance.Orders.CalculatePaymentInfoAmounts(CurrentState.Current.ShoppingCart.OrderCarrier, CurrentState.Current.Token);
}
}
You should consider calling the CalculateOrderTotals whenever the end customer performs an operation that affects the order grand total, so that the end customer always sees the updated values on the site.
Note that, it is not just adding or removing products from the shopping cart that will affect the order grand total. For example, when the customers login information changes, the customer might belong to a special user group, for which special pricelists or campaigns are applicable, which in turn would affect the grand total.