private FulfillmentFee GetFulfillmentFee(CommercePipelineExecutionContext context, FulfillmentFeeBook fulfillmentFeeBook, string currency, string fulfillmentMethodName, string fulfillmentTypeName) { FulfillmentFee fulfillmentFee = null; if (string.IsNullOrEmpty(fulfillmentMethodName)) { fulfillmentFee = GetFulfillmentFeeDefault(fulfillmentFeeBook, currency, fulfillmentMethodName); context.Logger.LogDebug($"Default fee found for fulfillment method '{fulfillmentMethodName}', fulfillment type '{fulfillmentTypeName}' and currency code '{currency}'."); } else { fulfillmentFee = GetFulfillmentFeeByType(fulfillmentFeeBook, currency, fulfillmentMethodName, fulfillmentTypeName); context.Logger.LogDebug($"Specific fee found for fulfillment method '{fulfillmentMethodName}', fulfillment type '{fulfillmentTypeName}' and currency code '{currency}'."); } return(fulfillmentFee); }
private void SetFulfillmentFeeAward(CommercePipelineExecutionContext context, CartLineComponent cartLineComponent, FulfillmentFee fulfillmentFee) { var awardedAdjustment = new CartLineLevelAwardedAdjustment() { Name = FulfillmentConstants.AwardedAdjustmentAttributes.FulfillmentFeeAttributeName, DisplayName = FulfillmentConstants.AwardedAdjustmentAttributes.FulfillmentFeeAttributeName, Adjustment = fulfillmentFee.Fee, AdjustmentType = context.GetPolicy <KnownCartAdjustmentTypesPolicy>().Fulfillment, IsTaxable = false, AwardingBlock = this.Name, IncludeInGrandTotal = false }; context.Logger.LogDebug(string.Format("{0} - Added fulfillment fee to line:{1} {2}", this.Name, fulfillmentFee.Fee.CurrencyCode, fulfillmentFee.Fee.Amount)); cartLineComponent.Adjustments.Add(awardedAdjustment); }