本文整理汇总了C#中IOrderTotalCalculationService.GetShoppingCartTotal方法的典型用法代码示例。如果您正苦于以下问题:C# IOrderTotalCalculationService.GetShoppingCartTotal方法的具体用法?C# IOrderTotalCalculationService.GetShoppingCartTotal怎么用?C# IOrderTotalCalculationService.GetShoppingCartTotal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOrderTotalCalculationService
的用法示例。
在下文中一共展示了IOrderTotalCalculationService.GetShoppingCartTotal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CalculateAdditionalFee
/// <summary>
/// Calculate payment method fee
/// </summary>
/// <param name="paymentMethod">Payment method</param>
/// <param name="orderTotalCalculationService">Order total calculation service</param>
/// <param name="cart">Shopping cart</param>
/// <param name="fee">Fee value</param>
/// <param name="usePercentage">Is fee amount specified as percentage or fixed value?</param>
/// <returns>Result</returns>
public static decimal CalculateAdditionalFee(this IPaymentMethod paymentMethod,
IOrderTotalCalculationService orderTotalCalculationService,
IList<OrganizedShoppingCartItem> cart,
decimal fee,
bool usePercentage)
{
if (paymentMethod == null)
throw new ArgumentNullException("paymentMethod");
if (fee == decimal.Zero)
return fee;
var result = decimal.Zero;
if (usePercentage)
{
//percentage
var orderTotalWithoutPaymentFee = orderTotalCalculationService.GetShoppingCartTotal(cart, usePaymentMethodAdditionalFee: false);
result = (decimal)((((float)orderTotalWithoutPaymentFee) * ((float)fee)) / 100f);
}
else
{
//fixed value
result = fee;
}
return result;
}