New York wrote:...One more question concerning Payment Director: if all payment methods have the same fee, and all payment methods meet the conditions for applying the fee, is there a way to always show the fee in the shopping cart order totals? Specifically, is it possible to show the fee in the shopping cart order totals before the user clicks the Checkout button?
It's not possible out of the box. If you custom code it, consider using a Checkout Attribute: create one with a single Attribute Value, give it a Price Adjustment, make it required. Then, you won't have to deal with how to make it part of the subtotal (because it's already supported).
A while back, I made a core change for a customer that did conditional checkout attributes (it was a bit of a hack). I've not yet created a "Checkout Attribute Director" plugin (I'm waiting to come up with a better name :))
I spent a few hours yesterday modifying OrderTotalCalulationService to add a fee to the subtotal, and I got it working beautifully... until the client changed the requirements. So I'm back at square one, but if anyone's interested, here's what you can do to add a fee to the subtotal:
I added a few localization settings which contain values for the requirements of the Small order fee:
SmallOrderFee.Requirement = 75
SmallOrderFee.Fee = 10
(This way the values aren't hardcoded and can be edited by anyone with proper access to the localization strings)
Then in GetShoppingCartSubTotal in OrderTotalCalculationService.cs, I added
if (subTotalExclTaxWithoutDiscount <= Convert.ToDecimal(_localizationService.GetResource("SmallOrderFee.Requirement")))
subTotalExclTaxWithoutDiscount += Convert.ToDecimal(_localizationService.GetResource("SmallOrderFee.Fee"));
(need to add "using Nop.Services.Localization;" in order to use _localizationService.GetResource)
That properly adds a fee of '_localizationService.GetResource("SmallOrderFee.Fee")' to a subTotal Excluding Tax Without Discount less than '_localizationService.GetResource("SmallOrderFee.Requirement")'
From there, I had to add logic to OrderTotals in ShoppingCartController.cs which returns a boolean (a new boolean I added to OrderTotalsModel named SmallOrderFeeApplied), and checks the subtotal of items in cart and compares to '_localizationService.GetResource("SmallOrderFee.Requirement")'. If the subtotal is less than, then return true, otherwise it's false.
In OrderTotals.cshtml, if Model.SmallOrderFeeApplied is true, then add a row to the cart totals table which displays the fee added to the subtotal.
It works, but only for subtotal excluding taxes and discount, and also excluding shipping. The problem is, after I got all that done, the client requested to factor in the shipping rate. So if the subtotal AND the shipping rate combined are less than $75, then add a $10 fee.
And of course the way I programmed it doesn't quite allow for checking the shipping rate at the point I perform the evaluation of the subtotal compared to the value in SmallOrderFee.Requirement.
So, I'll probably keep tinkering with that. In the mean time, is "OrderTotalWithoutPaymentFee" the only way to evaluate the current cost in Payment Director? Is there a way to evaluate with only subtotal and shipping charges (exclude tax and discounts from the evaluation)?
It looks like Shipping Director has some variables that won't work in Payment Director (i.e. "$SubTotalWithoutDiscounts").
Would it be possible to accomplish what I need with Shipping Director (add the $10 fee for (subtotal+shipping) <= 75)?