Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Solution: calculate tax only


wolf

Recommended Posts

Hi folks,

 

here is my solution to calculate the tax included in subtotal.

 

In germany tax is 16%.

 

In /includes/modules/order_total/ot_tax.php do the following:

 

Somewhere around line 39 there is:

 

---cut---------------------

$this->output[] = array('title' => $this->title . ':',

'text' => $currencies->format($order->info['tax'], true, $order->info['currency'], $order->info['currency_value']),

'value' => $order->info['tax']);

---cut---------------------

 

which i replaced with:

 

---cut---------------------

$sum_wo_tax = $order->info['subtotal'];

$tax_only = $sum_wo_tax - $sum_wo_tax/1.16;

$this->output[] = array('title' => $this->title . ':',

'text' => $currencies->format($tax_only),

'value' => $order->info['tax']);

---cut--------------------

 

note: text in blue is what i changed.

 

this works fine with 2.2, cause i?m using prices with tax included and i want to show the tax separatly.

 

Hope someone can use it :wink:

 

have fun, Olli

Link to comment
Share on other sites

Hi this doesnt seem to be doing anything at all, could you explain which page actually shows the price sub total and tax seperately. If it is supposed to be the cart page then it doesnt appear to be working. Any suggestions welcome.

 

regards,

MarkH

Link to comment
Share on other sites

Hi Mark,

 

...could you explain which page actually shows the price sub total and tax seperately.

 

make sure you got

 

define('DISPLAY_PRICE_WITH_TAX', true);

 

in /includes/application_top.php

 

You will see the tax in checkout_confirmation the first time, that?s where i need it here in germany, cause i?m working with prices where tax is already included in the database. Therefore i set tax to 0.00.

 

You will have to do some changes in /admin, if you want to use invoice and packing slip.

 

hope this helps, Olli

Link to comment
Share on other sites

..another thing

 

i?m not using tax zones, that?s why i made the changes from line 39 on.

 

On line 29 there is:

---cut-----------------

if (MODULE_ORDER_TOTAL_TAX_SHOW_GROUPS == 'true') ...

---cut-----------------

 

if you?re using tax zones, you have to do changes there.

 

cu Olli

Link to comment
Share on other sites

Hi Mark,

 

another method you could use ist following:

 

in /includes/modules/order_total/ot_tax.php

on line 20 there is:

$this->enabled = ((MODULE_ORDER_TOTAL_TAX_STATUS == 'true') ? true : false);

 

cause i don?t know where so set MODULE_ORDER_TOTAL_TAX_STATUS, i did the following:

 

$this->enabled = ((MODULE_ORDER_TOTAL_TAX_STATUS == 'true') ? true : true

 

that should show you the included tax from subtotal.

 

It?s a mucher nicer way then hardcoding the tax the way i did it before :lol: (don?t forget to delete the stuff in ot_tax.php from the first post, you don?t need it anymore)

 

 

 

i NEED to show the tax in the shopping cart also, can this be done?.

 

Cause i don?t need this feature, i didn?t check it out, but when flying over the code of /includes/modules/order_details.php there is a comment on line 87 which says "Tax (not in shopping cart, tax rate may be unknown)".

 

And really, when deleting the if-clause (just let echo ... remain), the programm can?t define the product tax rates. It gives 0%.

 

You propably have to add another class to get it?

 

cu Olli

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...