1 reply [Last post]
incaic's picture
Offline
Joined: 10/13/2007
Juice: 115
Was this information Helpful?

Hello,

I'm trying to think of the best way to hook into the tax system and create a tax line item per product(s) that is shipped from the same state it is delivered to. Shipping addresses are per product, not per entire store. I'd like to do this without hacking Ubercart.

Some solutions I thought it would make sense are:

1) Creating a custom uc_taxes_action_apply_tax action. (how/where do I do this?)
2) Implementing hook_calculate_tax (this calls #1 above with entire $order which is used to calculate tax and unfortunately uses the subtotal instead of a specific product for taxable dollar amount.)
3) Create an entirely new trigger/action/predicate for my situation.

Example: If a person ships to California and buys 1 product from Florida, 1 product from New York, and 1 product from California, she would see 2 tax line items (Florida & New York) with appropriate tax amount for each.

Can someone with better knowledge of the Ubercart tax system please advise.

Thanks,
Edwin-

incaic's picture
Offline
Joined: 10/13/2007
Juice: 115
[SOLVED] Item Specific Tax

For those with specific needs, one potential solution to having the ability to use custom code in creating a tax line_item (or more than one) is the following:

1) Implement hook_order() by copying the uc_taxes_order(...) function from uc_taxes.module to your custom module.

2) The one line you change is the second line inside the 'save' case

<?php
$line_items
= uc_line_item_tax('load', $arg1);
?>

Comment out this line and add your own function instead, such as

<?php
$line_items
= myModule_line_item_tax($arg1, $arg2);
?>

3) Then create your custom function myModule_line_item_tax. This is where you put your coded solution to your specific needs. Have it return an array of line items you want to add. Each line item of the return array should be in the following example format: (with your descriptions and calculated values, of course)

<?php
 
array(
   
'id' => 'tax'
   
,'title' => 'CA TAX'
   
,'amount' => 9.25
   
,'weight' => 9
   
,'data' => array(
     
'tax_id' => 1
     
,'tax_rate' => 0.0925
     
,'taxable_amount' => 100
     
,'tax_jurisdiction' => 'CA TAX'
   
)
  );
?>

To see how Ubercart sets these values, go to function uc_line_item_tax(...) in file uc_taxes.module.

Hope this helps someone.

e.