PDA

View Full Version : TAX removed at total



Sander
06-29-2005, 12:20 AM
when i order a product worth 100$, with 19% tax it cost 119$ in the shop.

i order it, everything goes fine, but at order total it calculates 100$ + shipping = 105$.

it leaves the tax away!!

why?

Sander
07-04-2005, 02:29 AM
nobody?

feemark
07-04-2005, 05:12 AM
Hi

In the Order Total Module, check that the Sort Order for Total is higher than Tax, so for example, Sub-Total is 1, Shipping is 2, Tax is 3, Total is 4. If Total is 4 and Tax is 5, or Total is 3 and Tax is 4, then it will not calculate it.

Sorry if this is something you have already covered, but I am new to this too.

Cheers

Sander
07-04-2005, 10:51 PM
No, thanks for the answer but this was already the case, problem is that it takes the actual product with out TAX already, and it never adds it back.

Even though it is displayed with tax in the shop..

Sander
07-05-2005, 02:17 AM
I have solved this by putting some of my 1337 pr0gr4mm1ng sk1llz in:

in /catalog/includes/modules/order_total from line 36 add:


////////// TAX CALCULATIONS START //////////

$query = "SELECT tax_rate FROM tax_rates WHERE tax_rates_id = 1";
$result = mysql_query($query) or die("query failed : " . mysql_error());
$table = mysql_fetch_array($result);
$tax_rate = stripslashes($table['tax_rate']);

$tax_rate2 = '1.' . $tax_rate;
$total = $order->info['subtotal'] * $tax_rate2;
$percent = 100;
$tax = $total / $percent * $tax_rate;

$_SESSION['total'] = number_format($total, 2, '.', ',');
$_SESSION['tax'] = number_format($tax, 2, '.', ',');

////////// TAX CALCULATIONS END //////////

this takes one defined tax rate in oscommerce with id = 1
i will built in support for countries later :)



in ot_total.php you replace the first part with this piece:


var $title, $output;

function ot_total() {
$this->code = 'ot_total';
$this->title = MODULE_ORDER_TOTAL_TOTAL_TITLE;
$this->description = MODULE_ORDER_TOTAL_TOTAL_DESCRIPTION;
$this->enabled = ((MODULE_ORDER_TOTAL_TOTAL_STATUS == 'true') ? true : false);
$this->sort_order = MODULE_ORDER_TOTAL_TOTAL_SORT_ORDER;
$this->title1 = MODULE_ORDER_TOTAL_TAX_TITLE;

$this->output = array();
}

function process() {
global $order, $currencies;

$this->output[] = array('title' => $this->title1 . ':',
'text' => $_SESSION['tax'] . 'EUR',
'value' => $order->info['total']);

$this->output[] = array('title' => $this->title . ':',
'text' => '<b>' . $_SESSION['total'] . 'EUR</b>',
'value' => $order->info['total']);
}


now tax shows up in the confirmation and in the email u get too :)

Sander
07-05-2005, 02:25 AM
in which variable is stored in what zone the customer is?

Sander
07-05-2005, 03:16 AM
forget it i already found it, changed this for tax selection based on country:


// decide whether customer is in the netherlands or not
if ($_SESSION['customer_country_id'] == 150) { $zone = nl; } else { $zone = other; }

// switch the query based upon country
switch($zone) {
CASE other:
$query = "SELECT tax_rate FROM tax_rates WHERE tax_rates_id = 2";
$result = mysql_query($query) or die("query failed : " . mysql_error());
$table = mysql_fetch_array($result);
$tax_rate = stripslashes($table['tax_rate']);
break;
DEFAULT:
$query = "SELECT tax_rate FROM tax_rates WHERE tax_rates_id = 1";
$result = mysql_query($query) or die("query failed : " . mysql_error());
$table = mysql_fetch_array($result);
$tax_rate = stripslashes($table['tax_rate']);
}

coeus
07-19-2005, 06:34 PM
Hey, Thanks for the hack, I was wondering,


I have solved this by putting some of my 1337 pr0gr4mm1ng sk1llz in:

in /catalog/includes/modules/order_total from line 36 add:

What file's the file? "order_total" is a directory.. did you mean:
I have solved this by putting some of my 1337 pr0gr4mm1ng sk1llz in:

/catalog/includes/modules/order_total/ot_total.php

Thanks

michael_s
07-20-2005, 09:38 AM
Do not use this workaround, as it does not actually address the bug that causes the tax problem in the first place.

This bug has been resolved and you can get the official fix here:
http://bugtrack.oscmax.com/view.php?id=29

Sander
08-25-2005, 01:51 AM
he is right, use the fix from the bugtracker first.

my fix is only working on my specific shop.