ok - well I just wrote the code and tested it.
not too difficult
one module needs to be modified:
/includes/classes/order.php
I made three changes to this module. I have not looked at 1.5 but I suspect the code is very similar
You can take a look in your code and see how similar they are.
1) code needs to be added to read the customers_whole field from the customers table so that you can check to see if this is a wholesaler/dealer (and skip the sales tax calculation)
that''s easy.
find this code:
PHP Code:
$customer_address_query = "select c.customers_firstname, c.customers_lastname, c.customers_telephone,
and replace it with:
PHP Code:
$customer_address_query = "select c.customers_firstname, c.customers_lastname, c.customers_telephone, c.customers_whole,
then find:
PHP Code:
// find product's tax rate and description
$products_tax = $this->products[$index]['tax'];
$products_tax_description = $this->products[$index]['tax_description'];
and insert this code after it (please bear in the mind that this code may be superfluous since we'll be avoiding the sales tax calculations altogether next, but I like to be safe)
PHP Code:
if ($customer_address->fields['customers_whole'] > 0)
{ $products_tax = 0;
$this->products[$index]['tax'] = 0;
$tax_add = 0;
$this->products[$index]['tax_description'] = '';
}
then finally there a chunk of code RIGHT BELOW what we just added that does all the sales tax calculation.
what I found in the standard 1.39 module is shown below:
PHP Code:
if (DISPLAY_PRICE_WITH_TAX == 'true') {
// calculate the amount of tax "inc"luded in price (used if tax-in pricing is enabled)
$tax_add = $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax)));
} else {
// calculate the amount of tax for this product (assuming tax is NOT included in the price)
// $tax_add = zen_round(($products_tax / 100) * $shown_price, $currencies->currencies[$this->info['currency']]['decimal_places']);
$tax_add = ($products_tax/100) * $shown_price;
}
$this->info['tax'] += $tax_add;
foreach ($taxRates as $taxDescription=>$taxRate)
{
$taxAdd = zen_calculate_tax($this->products[$index]['final_price']*$this->products[$index]['qty'], $taxRate)
+ zen_calculate_tax($this->products[$index]['onetime_charges'], $taxRate);
if (isset($this->info['tax_groups'][$taxDescription]))
{
$this->info['tax_groups'][$taxDescription] += $taxAdd;
} else
{
$this->info['tax_groups'][$taxDescription] = $taxAdd;
}
}
I added an if statement to wrap this code and only execute it if the customers is a non wholesaler/dealer
my code is shown below:
PHP Code:
// jjj added
if ($customer_address->fields['customers_whole'] == 0)
{
if (DISPLAY_PRICE_WITH_TAX == 'true') {
// calculate the amount of tax "inc"luded in price (used if tax-in pricing is enabled)
$tax_add = $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax)));
} else {
// calculate the amount of tax for this product (assuming tax is NOT included in the price)
// $tax_add = zen_round(($products_tax / 100) * $shown_price, $currencies->currencies[$this->info['currency']]['decimal_places']);
$tax_add = ($products_tax/100) * $shown_price;
}
$this->info['tax'] += $tax_add;
foreach ($taxRates as $taxDescription=>$taxRate)
{
$taxAdd = zen_calculate_tax($this->products[$index]['final_price']*$this->products[$index]['qty'], $taxRate)
+ zen_calculate_tax($this->products[$index]['onetime_charges'], $taxRate);
if (isset($this->info['tax_groups'][$taxDescription]))
{
$this->info['tax_groups'][$taxDescription] += $taxAdd;
} else
{
$this->info['tax_groups'][$taxDescription] = $taxAdd;
}
}
// jjj added
}
GOOD LUCK!
Bookmarks