=== modified file 'uc_taxes/uc_taxes.module' --- uc_taxes/uc_taxes.module 2009-09-21 14:13:04 +0000 +++ uc_taxes/uc_taxes.module 2009-10-13 14:26:01 +0000 @@ -242,21 +242,13 @@ */ function uc_line_item_tax_subtotal($op, $order) { $amount = 0; - if (is_array($order->products)) { - foreach ($order->products as $item) { - $amount += $item->price * $item->qty; - } - } if (is_array($order->line_items)) { foreach ($order->line_items as $key => $line_item) { - if ($line_item['type'] == 'subtotal') { - continue; - } if (substr($line_item['type'], 0, 3) != 'tax') { $amount += $line_item['amount']; $different = TRUE; } - else { + elseif ($line_item['type'] != 'subtotal') { $has_taxes = TRUE; } } @@ -484,7 +476,7 @@ /** * Calculate tax for a single product. */ -function uc_taxes_apply_item_tax($item, $tax) { +function uc_taxes_apply_item_tax($item, $order, $tax) { $node = node_load($item->nid); // Special handling for manually added "Blank line" products. @@ -497,7 +489,21 @@ // Tax products if they are of a taxed type and if it is shippable if // the tax only applies to shippable products. if (in_array($node->type, $tax->taxed_product_types) && ($tax->shippable == 0 || $node->shippable == 1)) { - return $item->price * $item->qty; + $price_info = array( + 'price' => $item->price, + 'qty' => $item->qty, + ); + $context = array( + 'type' => 'order_product', + 'revision' => 'altered', + 'subject' => array( + 'order' => $order, + 'product' => $item, + 'node' => $node, + ), + ); + + return uc_price($price_info, $context); } } @@ -516,7 +522,7 @@ $taxable_amount = 0; if (is_array($order->products)) { foreach ($order->products as $item) { - $taxable_amount += uc_taxes_apply_item_tax($item, $tax); + $taxable_amount += uc_taxes_apply_item_tax($item, $order, $tax); } } $taxed_line_items = $tax->taxed_line_items;