Jump to content

If not in state, don't charge product tax.


Recommended Posts

I've set everything up correctly to charge tax only to residents of Texas. That part works, but the products I have set up to not charge taxes are still charging them in the state of Texas... any ideas?

$20 to the PayPal account who gets the right answer first. Just rolled the site live today.


Update:

I've figured out that it's either all or nothing with State Tax and Product Tax is where the individual rules get applied per product. Now, what I need is to use Product Tax, but exclude any taxes being charged outside of Texas.

What I'm thinking is in classes\Tax.php editing:

if ($tax_behavior == PS_STATE_TAX)
                   return Tax::getRateByState(intval($address_ids['id_state']));



to read something like:

if ($tax_behavior == PS_STATE_TAX AND STATE !== 'Tx')
                   return Tax::getRateByState(intval($address_ids['id_state']));



Obviously this is nowhere near right, but these are just my thoughts.

Link to comment
Share on other sites

I am having simular troubles I have a sales tax for texas that does not show up I have set the products to no tax and it doesnt show up if I set the products to sales tax but apply this tax for only texas the tax is added for everyone.

mechanictoolsonline.com/index.php

Link to comment
Share on other sites

Alright, so I've done a fresh install on my local box and used all the default settings with the exception of local taxes and it works fine. So, I know it's an edit I've done to the cart. Any direction a moderator can point me in as far as the file that messed up tax?

Link to comment
Share on other sites

I think I've finally got a grasp on how tax works and know the issue. Normally this is the process:

State Tax Selected > User lives in state > All products taxed

I need:

State tax selected > User lives in state > Tax given to individual product > Product is taxed

or

State tax selected > User lives in state > No Tax selected for product > Product not taxed

Please, any thoughts?

Link to comment
Share on other sites

I'm guessing this is the code I'll need to edit:

static public function getApplicableTax($id_tax, $productTax)
   {
       global $cart, $cookie, $defaultCountry;

       $id_address_invoice = intval((Validate::isLoadedObject($cart) AND $cart->id_address_invoice) ? $cart->id_address_invoice : (isset($cookie->id_address_invoice) ? $cookie->id_address_invoice : 0));
       /* If customer has an address (implies that he is registered and logged) */
       if ($id_address_invoice AND $address_ids = Address::getCountryAndState($id_address_invoice))
       {
           $id_zone_country = Country::getIdZone(intval($address_ids['id_country']));
           /* If customer's invoice address is inside a state */
           if ($address_ids['id_state'])
           {
               $state = new State(intval($address_ids['id_state']));

               if (!Validate::isLoadedObject($state))
                   die(Tools::displayError());
               /* Return tax value depending to the tax behavior */
               $tax_behavior = intval($state->tax_behavior);
               if ($tax_behavior == PS_PRODUCT_TAX)
                   return $productTax * Tax::zoneHasTax(intval($id_tax), intval($id_zone_country));
               if ($tax_behavior == PS_STATE_TAX)
                   return Tax::getRateByState(intval($address_ids['id_state']));
               if ($tax_behavior == PS_BOTH_TAX)
                   return ($productTax * Tax::zoneHasTax(intval($id_tax), intval($id_zone_country))) + Tax::getRateByState(intval($address_ids['id_state']));
               /* Unknown behavior */
               die(Tools::displayError('Unknown tax behavior!'));
           }
           /* Else getting country zone tax */
           if (!$id_zone = Address::getZoneById($id_address_invoice))
               die(Tools::displayError());
           return $productTax * Tax::zoneHasTax(intval($id_tax), intval($id_zone));
       }
       /* Default tax application */
       if (!Validate::isLoadedObject($defaultCountry))
           die(Tools::displayError());
       return $productTax * Tax::zoneHasTax(intval($id_tax), intval($defaultCountry->id_zone));
   }



Any ideas on what to do? I'm going to plug away at it, see if I come up with anything. I'm not too familiar with this though.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...