Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Two decimals in tax


redrum

Recommended Posts

I want to display 2 decimals in tax in the order total at checkout. I don't want to display 2 decimals anywhere else in the shop, therefore I can't change this in admin, this has to be hard coded.

Can anyone help me out with this?

 

Below is my ot_tax.php

<?php
/*
 $Id: ot_tax.php,v 1.3 2005/02/19 09:01:10 joacim Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License

 [Joacim J?rkeborn, 2005-02-18]
 Modified for viewing taxes in different ways, more support for multiple tax rates and 
 able to split the display per tax rate.  
*/

class ot_tax {
var $title, $output;

function ot_tax() {
	$this->code = 'ot_tax';
	$this->title = MODULE_ORDER_TOTAL_TAX_TITLE;
	$this->description = MODULE_ORDER_TOTAL_TAX_DESCRIPTION;
	$this->enabled = ((MODULE_ORDER_TOTAL_TAX_STATUS == 'true') ? true : false);
	$this->sort_order = MODULE_ORDER_TOTAL_TAX_SORT_ORDER;
	$this->output = array();
}

/* **************************************************
 * Summerar totala momsen p? en rad f?r momssatserna 
 * ************************************************** */
function process() {
	global $order, $currencies;

	if(MODULE_ORDER_TOTAL_TAX_SHOW_HEADER == 'true') {
		$this->output[] = array('title' => '<b>' . MODULE_ORDER_TOTAL_TAX_HEADER . '</b>',
								'text' => '',
								'value' => '');		
	}
	// Calculate the total tax amount
	$num = 0;
	$total_moms_summa = 0;
	reset($order->info['tax_groups']);
	while (list($key, $value) = each($order->info['tax_groups'])) {
		if ($value > 0) {
			$total_moms_summa=$total_moms_summa+$value; // Summerar totala momsen
			$num++;
		}
	}
	$moms_desc = '';
	if(DISPLAY_PRICE_WITH_TAX == 'false') {
		// Skriver ut totalamomsen
		$this->output[] = array(
			'title' =>MODULE_ORDER_TOTAL_TAX_TITLE.':',
			'text' => $currencies->format($total_moms_summa, true, $order->info['currency'], $order->info['currency_value']),
			'value' => $total_moms_summa);
	} else {
		// If more than one tax group was used, display the total amount of tax
		if ( MODULE_ORDER_TOTAL_TAX_INCL_SPLITTED == 'false' || (MODULE_ORDER_TOTAL_TAX_INCL_SPLITTED == 'true' && $num > 1)) {
			$this->output[] = array('title' => MODULE_ORDER_TOTAL_TAX_INCL_TITLE . ':',
									'text' => $currencies->format($total_moms_summa, true, $order->info['currency'], $order->info['currency_value']),
									'value' => $order->info['total']);
		}

		if (MODULE_ORDER_TOTAL_TAX_INCL_SPLITTED == 'true' ) {
			// Display the taxes per tax group
			reset($order->info['tax_groups']);
			while (list($key, $value) = each($order->info['tax_groups'])) {
				if ($value > 0) {
					$this->output[] = array('title' => MODULE_ORDER_TOTAL_TAX_SPLIT_TITLE . $key . ':',
											'text' =>  $currencies->format($value, false, $order->info['currency'], $order->info['currency_value']),
											'value' => $value);
				}
			}
		}
	}


}
// ***************************************************

function check() {
	if (!isset($this->_check)) {
		$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_TAX_STATUS'");
		$this->_check = tep_db_num_rows($check_query);
	}
	return $this->_check;
}

function keys() {
	return array('MODULE_ORDER_TOTAL_TAX_STATUS', 'MODULE_ORDER_TOTAL_TAX_SORT_ORDER','MODULE_ORDER_TOTAL_TAX_SHOW_HEADER' ,'MODULE_ORDER_TOTAL_TAX_INCL_SPLITTED');
}

function install() {
	tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Display Tax', 'MODULE_ORDER_TOTAL_TAX_STATUS', 'true', 'Do you want to display the order tax value?', '6', '1','tep_cfg_select_option(array(\'true\', \'false\'), ', now())");
	tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_ORDER_TOTAL_TAX_SORT_ORDER', '3', 'Sort order of display.', '6', '2', now())");

	tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Display tax specification header', 'MODULE_ORDER_TOTAL_TAX_SHOW_HEADER', 'false', 'Enable to show the tax specification header?', '6', '3','tep_cfg_select_option(array(\'true\', \'false\'), ', now())");
	tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Display amount splitted per tax rate', 'MODULE_ORDER_TOTAL_TAX_INCL_SPLITTED', 'false', 'Enable to split the tax amounts on the different tax rates?', '6', '4','tep_cfg_select_option(array(\'true\', \'false\'), ', now())");

}

function remove() {
	tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
}
}
?>

 

Thanks,

Fredrik

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...