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
Example:
Shopping cart includes:
- Product 1: €15 base price - 23% VAT
- Product 2: €20 base price - 6.5% VAT
Checkout Process:
- 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.
Comments
To make it more simple for
To make it more simple for everyone & because I really need an asnswer to this, this is a simplified version of my question:
All products in my store will have either 23% tax or 6.5% tax (will it be taxonomy reference or VAT/Sales Tax, I don't know yet).
Product prices are initially displayed without tax to customers.
Depending on the total of the order (calculated by adding all product prices without tax), customers should get a discount (5% discount for total up to €50, 8% discount for total from €50.01 to €100 etc).
So, i have to
1. FIRST define the discount my customer should get (by adding base prices of procucts in the cart without taking into account their 23% or 6.5% tax,
2. THEN add products' taxes to base prices and
3. FINALLY apply the discount defined in 1st step above to define the final cost
I would really appreciate your help here guys...!