How to perform a complex calculation of order's final cost, depending on different VATs & discounts
Here's is what I want to accomplish:
- There are 2 VAT taxes in my country: VAT1:6.5% & VAT2: 23%. Every product has to be matched with 1 of these 2 VATs (taxonomy term reference field in product type?)
- A discount will always be available, depending on total order's amount (e.g. €0,01-€50,00: -5%, €50,01-€80,00: -8%, €80,01-€110,00: -10% etc)
What I want to accomplish:
- Customer adds products to cart and heads to checkout. According to order's total (addition of products' base prices), the appropriate discount will be applied.
- Final Price = (Products' base prices + their total VATs)*Discount + Shipping Cost
Shopping cart includes:
- Product 1: €15 base price - 23% VAT
- Product 2: €20 base price - 6.5% VAT
- Total base price = €15 + €20 = €35. As a result, the customer will be awarded with a -5% discount (see available discount rates above)
- Order's total including products' VATs = (€15 + €15*0.23) + (€20 + €20*0.065) = €18.45 + €21.3 = €39.75
- The -5% sale scale is applied: €39.75 - €39.75*0.08 = €36.57 and that's what the customer has to pay for the products in his/her cart
- Order's weight is calculated and a shipping flat rate is applied (I have this functionality already working). As a result, the shipping cost is added to €36.57 and we finally get the sum that the customer will have to pay using one of available payment methods.
I would appreciate your suggestions on how to make this happen. Tricky parts are that different products can have different VAT (23% or 6.5%). Also, the discount has first to be calculated depending on base prices and then applied to full (inclusing VAT) prices. It would also be nice if VATs & discount were displayed to customer in order's review.