i am trying to set a tax rate for a guest (not logged in) based on a coupon code.
i have tried every singleton i can think of and am having trouble even manually setting the customertaxrateid that i would like to set.
any ideas?
i am trying to set a tax rate for a guest (not logged in) based on a coupon code.
i have tried every singleton i can think of and am having trouble even manually setting the customertaxrateid that i would like to set.
any ideas?
so update and answer... i made a really stupid mistake placing my code but after finding a complete lack of information about these subjects on the web... i thought i would share some code... commented instead of the custom solution i am using... but it works!!!
the code needs to be added in: /app/code/core/Mage/Tax/Model/Calculation.php
$couponCode = Mage::getSingleton('checkout/cart')->getQuote()->getCouponCode(); if (!empty($couponCode)) {
$db = Mage::getSingleton('core/resource')->getConnection('core_read');
$query = ""//put your sql query here since magento makes it hard to respect MVC when a group of setters and getters think you are running mysql4 even though you are using mysql5
$result = $db->query($query);
while ($row = $result->fetch() ) {
//lazy method to avoid the need for more error handling
$customerTaxClass = $row['class_id'];
}
}
it should be done in the getRateRequest function before it creates the $request to return.