function uc_coupon_tax_adjustment in Ubercart Discount Coupons 7.2
Same name and namespace in other branches
- 6 uc_coupon.module \uc_coupon_tax_adjustment()
- 7.3 uc_coupon.module \uc_coupon_tax_adjustment()
Handle tax on coupons by calculating tax for individual discounted prices. This is designed to work with a patch to uc_taxes from http://drupal.org/node/1155656.
1 string reference to 'uc_coupon_tax_adjustment'
- uc_coupon_uc_line_item in ./
uc_coupon.module - Implements hook_uc_line_item().
File
- ./
uc_coupon.module, line 1589
Code
function uc_coupon_tax_adjustment($price, $order, $tax) {
$amount = 0;
if (isset($order->data['coupons'])) {
foreach ($order->data['coupons'] as $discounts) {
foreach ($discounts as $nid => $item) {
$node = node_load($nid);
if (in_array($node->type, $tax->taxed_product_types) && ($tax->shippable == 0 || $node->shippable == 1)) {
$amount += (isset($item->pretax_discount) ? $item->pretax_discount : $item->discount) * ($price > 0 ? 1 : -1);
}
}
}
}
return $amount;
}