I've been trying to find a good solution for this online but without success so would like to get your insight into a "best way" of solving this task.
The task is that when a customer chooses to pay their order using invoice a certain handling cost for this needs to be added to the order. For shipping options this is built into the commerce platform but I can't find a similar solution for payment options. How would you go about solving this issue in the best (and easiest ;-)) way?
Options I can think of are:
- Adding a lineitem to the cart, so pretty much handle the payment handling cost as a product
- Adding a meta field to the cart where information about payment handling cost is stored, which then needs to be taken into account on different places in the solution
Any suggestions about how to handle this, or is there any hidden gems in the platform that I don't know of?
If it is the only handling cost you have i would recommend that you use the HandlingTotal field on OrderForm and take it into account in your calculations.
By using this field it will be automatically displayed together with the other sums in commerce when looking on orders.
Sounds like a solution that could work. However, when setting HandlingCost on the cart, accept the changes on the cart and then execute the CartValidateWorkflow, after that the handlingcost is still 0. I've also tried to reproduce this in Quicksilver (version 9.24.1 of Commerce) by setting HandlingCost on the cart when adding a product to the cart but the same thing happens there. Have you successfully implemented this in a solution and if so, what am I doing wrong?
We have done it in several solutions but we normally don't use the workflows.
I have to ask thou, did you set the HandlingTotal on the OrderForm as i suggested or directly on the Cart/OrderGroup?
The default implementation of CartValidateWorkflow uses the CalculateTotalsActivity which sets the HandlingTotal of the Cart/OrderGroup to the sum of the HandlingTotals on it's OrderForms.
You were right, I tried adding it to the cart directly, adding it to the OrderForm works better. However, the Total cost for the cart does not seem to include the HandlingCost after adding it correctly to the OrderForm. It includes the total cost of the articles in the cart and the cost for shipping, if any, but not the handling cost. Is this something that you've come across as well?
Yes that is the standard way episerver calculates totals unfortunatly.
Using the new order api's you can register your own implementations of IOrderFormCalculator and IOrderGroupCalculator to change it, inherit from the default implementations if you don't want to written it all again.
Ok, yes that's a bit unfortunate. I actually sent this question to episerver support also and they created a bug report for it, let's wait and see if that results in a change in the platform or not.
Thanks for your help!
Yes i suspect it is a legacy from the old commerce solution which was from america, where they don't really allow charging for payment options if i recall correctly.
FYI, the issue of HandlingTotal not being included in the Total cost for a order form has been solved in a recent release: http://world.episerver.com/releases/episerver---update-139/.