I have created one coupon with "Fixed Amount" that is suppose to $100 and I am adding product to the cart which price is $100. Now I have selected in backend in System->configuration->tax->calculation setting "Apply Customer Tax is After Discount" and "Apply Discount on price is Excluding tax".
Now below is scenarios : 1) When I am adding product to cart and applying coupon then grand total become 0.(because coupon value 100 and Product price is 100 so it's become 0) now if I press on checkout button,in checkout page price displaying $0 and tax also showing $0.
I want to apply tax once if I apply coupon and my tax should get calculated based on some amount that is $40(for example). if I have created tax rule for state with amount 10% then my tax should calculated on $40*10/100 = $4 should tax added to total before clicking to checkout button.
Is anyone know in which observer I need to take look up for adding those conditions.
I have tried following things : I am observing following observer :
<checkout_cart_save_after>
<observers>
<NamespaceModulename>
<type>singleton</type>
<class>Namespace_Modulename_Model_Observer</class>
<method>updateTaxAfterDiscountApplied</method>
</NamespaceModulename>
</observers>
</checkout_cart_save_after>
and following is my method code :
public function updateTaxAfterDiscountApplied()
{
$quote = Mage::getModel('checkout/cart')->getQuote();
$coupon_code = $quote->getCouponCode();
if($coupon_code)
{
$coupon_rule_id = $quote->getAppliedRuleIds();
echo 'rule id'.$coupon_rule_id;
echo $coupon_code.'couponcode';
}
if($coupon_rule_id){
$con = Mage::getSingleton('core/resource')->getConnection('core_read');
$sale_rule_result = $con->fetchAll("SELECT * FROM salesrule where rule_id=".$coupon_rule_id);
foreach($sale_rule_result as $rule){
echo 'tax price'.$rule['tax_calculation_price'];
}
}
}
in above method "tax_calculation_price" is my custom field which is used when I apply coupon and my grand total zero. then I have this field which is used to calculate tax on based on tax calculation. for example tax_calculation_price = 40 then and for suppose canada->ontario my tax rate is 12% then it should calculate 12% of 40 and add to grand total. so how to fetch tax so that I can calculate it with tax_calculation_price. ? any help appreciate.