Jump to content

Tex Exempt / Wholesale Group without buying yet another module


Recommended Posts

I really don't need another module and the bells and whistles that go along with it. I really just need a code mod to make one group be tax exempt. Using 1.5.3.1

 

I've tried this:

class Tax extends TaxCore
{
/**
* Returns the product tax
*
* @param integer $id_product
* @param integer $id_country
* @return Tax
*/
public static function getProductTaxRate($id_product, $id_address = null, Context $context = null)
{
/*if ($context == null)
 $context = Context::getContext();
$address = Address::initialize($id_address);
$id_tax_rules = (int)Product::getIdTaxRulesGroupByIdProduct($id_product, $context);
$tax_manager = TaxManagerFactory::getManager($address, $id_tax_rules);
$tax_calculator = $tax_manager->getTaxCalculator();
return $tax_calculator->getTotalRate();
*/
	    if (is_numeric($id_address)) {
					    $address = new Address((int)($id_address));
			    // get customer groups to check for tax exempt group
			    $groups = Customer::getGroupsStatic((int)($address->id_customer));
			    //var_dump($groups);
			    foreach ($groups as $g) {
							    $query = "SELECT name FROM ps_group_lang WHERE id_group=$g AND id_lang=1";
							    $groupname = Db::getInstance()->getValue($query);

							    if (strtolower(substr($groupname, 0, 9))=="wholesale"){
									 return 0;
									 }
							   }
					   }
	    $context = Context::getContext();
 $address = Address::initialize($id_address);
 $id_tax_rules = (int)Product::getIdTaxRulesGroupByIdProduct($id_product, $context);
 $tax_manager = TaxManagerFactory::getManager($address, $id_tax_rules);
 $tax_calculator = $tax_manager->getTaxCalculator();
 return $tax_calculator->getTotalRate();		
}

 

AND this

static public function getApplicableTax($id_tax, $productTax)
{
    global $cart, $cookie, $defaultCountry;
    $noTaxGroup =3; // Group number that is tax exempt
    $customer = new Customer($cart->id_customer);
		    if ($customer->isMemberOfGroup($noTaxGroup)) {
		    return 0;
    }

 

to no avail.

The second option seems more what I'm looking for because I don't see how the tax exempt group will ever change. But that code was for 1.4

 

Please help! Thanks!

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...