Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

NEW! Complete Order Editing Tool!


jhilgeman

Recommended Posts

Hi,

 

I have a little problem here. If I add a Shipping Insurance to the order, its value is automatically registered as ot_custom in the orders_total table, which messes up my Monthly Sales Report calculations. How can I change ot_custom to ot_insurance for Shipping Insurance?

 

Thanks.

Link to comment
Share on other sites

Hi,

 

I have a little problem here. If I add a Shipping Insurance to the order, its value is automatically registered as ot_custom in the orders_total table, which messes up my Monthly Sales Report calculations. How can I change ot_custom to ot_insurance for Shipping Insurance?

 

Thanks.

 

Try this-

 

In edit_orders.php, find and delete this:

$TotalsArray[] = array(
	"Name" => "", 
	"Price" => "", 
	"Class" => "ot_custom", 
	"TotalID" => "0");

 

Next find and delete

array_pop($TotalsArray);

 

Then, change

if(//tax, subtotal, and total are not editable, but have all the same format
	$TotalDetails["Class"] == "ot_total" || 
	$TotalDetails["Class"] == "ot_subtotal" || 
	$TotalDetails["Class"] == "ot_tax")
	{

		echo '	<tr>' . "\n" .
			   '		<td align="right" class="' . $TotalStyle . '">' . $TotalDetails["Name"] . '' .
			   '		<td align="right" class="' . $TotalStyle . '">' . 
						"<input name='" . $TotalDetails["Name"] . "' size='10' value='" . $TotalDetails["Price"] . "' id='" . $id . "' readonly='readonly' />" . 
						"<input name='update_totals[$TotalIndex][title]' type='hidden' value='" . trim($TotalDetails["Name"]) . "'>" . 
						"<input name='update_totals[$TotalIndex][value]' type='hidden' value='" . $TotalDetails["Price"] . "'>" . 
						"<input name='update_totals[$TotalIndex][class]' type='hidden' value='" . $TotalDetails["Class"] . "'>\n" . 
						"<input type='hidden' name='update_totals[$TotalIndex][total_id]' value='" . $TotalDetails["TotalID"] . "'>" . '' . 
			   '		<td align="right" class="' . $TotalStyle . '">' . tep_draw_separator('pixel_trans.gif', '1', '17') . '' . 
			   '	</tr>' . "\n";
	} else { //the other total components are editable

to

if(//tax, subtotal, and total are not editable, but have all the same format
	$TotalDetails["Class"] == "ot_total")
	{

		//first we put an insurance box in
		echo '	<tr>' . "\n" .
  '		 <td align="right" class="' . $TotalStyle . '"><input name="update_totals[' . $TotalIndex . '][title]" size="' . $max_length . '" value="(insurance)" /></td>' . "\n" .
  '		 <td align="right" class="' . $TotalStyle . '">' .
	"<input name='update_totals[$TotalIndex][value]' size='10' value='' id='ot_insurance" . $TotalIndex . "' onKeyUp=\"getTotals('shipping', '" . $default_tax_name . "')\" />" . 
	"<input name='update_totals[$TotalIndex][class]' type='hidden' value='ot_insurance'>" .
	"<input name='update_totals[$TotalIndex][total_id]' type='hidden' value='0'>" . "\n" .
'		 <td align="right" class="' . $TotalStyle . '"><b>' . tep_draw_separator('pixel_trans.gif', '1', '17') . '</b>' . "\n" .
			   '	</tr>' . "\n";
			   $TotalIndex++;

		//then a custom
		echo '	<tr>' . "\n" .
  '		 <td align="right" class="' . $TotalStyle . '"><input name="update_totals[' . $TotalIndex . '][title]" size="' . $max_length . '" value="" /></td>' . "\n" .
  '		 <td align="right" class="' . $TotalStyle . '">' .
	"<input name='update_totals[$TotalIndex][value]' size='10' value='' id='ot_custom" . $TotalIndex . "' onKeyUp=\"getTotals('shipping', '" . $default_tax_name . "')\" />" . 
	"<input name='update_totals[$TotalIndex][class]' type='hidden' value='ot_custom'>" .
	"<input name='update_totals[$TotalIndex][total_id]' type='hidden' value='0'>" . "\n" .
'		 <td align="right" class="' . $TotalStyle . '"><b>' . tep_draw_separator('pixel_trans.gif', '1', '17') . '</b>' . "\n" .
			   '	</tr>' . "\n";
			   $TotalIndex++;

		echo '	<tr>' . "\n" .
			   '		<td align="right" class="' . $TotalStyle . '"><b>' . $TotalDetails["Name"] . '</b></td>' .
			   '		<td align="right" class="' . $TotalStyle . '">' . 
						"<input name='" . $TotalDetails["Name"] . "' size='10' value='" . $TotalDetails["Price"] . "' id='" . $id . "' readonly='readonly' />" . 
						"<input name='update_totals[$TotalIndex][title]' type='hidden' value='" . trim($TotalDetails["Name"]) . "'>" . 
						"<input name='update_totals[$TotalIndex][value]' type='hidden' value='" . $TotalDetails["Price"] . "'>" . 
						"<input name='update_totals[$TotalIndex][class]' type='hidden' value='" . $TotalDetails["Class"] . "'>\n" . 
						"<input type='hidden' name='update_totals[$TotalIndex][total_id]' value='" . $TotalDetails["TotalID"] . "'>" . '</td>' . 
			   '		<td align="right" class="' . $TotalStyle . '"><b>' . tep_draw_separator('pixel_trans.gif', '1', '17') . '</b>' . 
			   '	</tr>' . "\n";

	} elseif(//tax, subtotal, and total are not editable, but have all the same format
	$TotalDetails["Class"] == "ot_subtotal" || 
	$TotalDetails["Class"] == "ot_tax")
	{

		echo '	<tr>' . "\n" .
			   '		<td align="right" class="' . $TotalStyle . '"><b>' . $TotalDetails["Name"] . '</b></td>' .
			   '		<td align="right" class="' . $TotalStyle . '">' . 
						"<input name='" . $TotalDetails["Name"] . "' size='10' value='" . $TotalDetails["Price"] . "' id='" . $id . "' readonly='readonly' />" . 
						"<input name='update_totals[$TotalIndex][title]' type='hidden' value='" . trim($TotalDetails["Name"]) . "'>" . 
						"<input name='update_totals[$TotalIndex][value]' type='hidden' value='" . $TotalDetails["Price"] . "'>" . 
						"<input name='update_totals[$TotalIndex][class]' type='hidden' value='" . $TotalDetails["Class"] . "'>\n" . 
						"<input type='hidden' name='update_totals[$TotalIndex][total_id]' value='" . $TotalDetails["TotalID"] . "'>" . '</td>' . 
			   '		<td align="right" class="' . $TotalStyle . '"><b>' . tep_draw_separator('pixel_trans.gif', '1', '17') . '</b>' . 
			   '	</tr>' . "\n";
	} else { //the other total components are editable

 

Finally, find

} else { // New Insert (ie ot_custom)

and change it to

} elseif (tep_not_null($ot_value)) { // New Insert (ie ot_custom)

 

You should then have one blank set of inputs for insurance (clearly marked) and one blank set of inputs for custom per order.

Do, or do not. There is no try.

 

Order Editor 5.0.6 "Ultra Violet" is now available!

For support or to post comments, suggestions, etc, please visit the Order Editor support thread.

Link to comment
Share on other sites

Stew, that works. Thanks. I have a question, though. The field (insurance) is always displayed even when insurance was added to the order.

Shipping Insurance: 4.20

(insurance)

Is there any how to hide it when the insurance is already added to the order?

 

Thanks.

Link to comment
Share on other sites

Stew, that works. Thanks. I have a question, though. The field (insurance) is always displayed even when insurance was added to the order.

 

Is there any how to hide it when the insurance is already added to the order?

 

Thanks.

 

But of course!

 

Change

foreach($TotalsArray as $TotalIndex => $TotalDetails)
{
	$TotalStyle = "smallText";

 

to

$insurance_already = false;
foreach($TotalsArray as $TotalIndex => $TotalDetails)
{
	$TotalStyle = "smallText";


	if ($TotalDetails["Class"] == "ot_insurance") {
		 $insurance_already = true;
		 }

 

Then change

//first we put an insurance box in

 

to

//first we put an insurance box in
		if (!$insurance_already){

 

and then change

//then a custom

 

to

 }
		//then a custom

 

and you should be set on that front. Also, if you want to save yourself some time in the future you can change

value="(insurance)"

to

value="Shipping Insurance:"

Do, or do not. There is no try.

 

Order Editor 5.0.6 "Ultra Violet" is now available!

For support or to post comments, suggestions, etc, please visit the Order Editor support thread.

Link to comment
Share on other sites

djmonkey1 .. you are the man. I was wondering if you had time to help me with a small problem that I have gotten so close .. but no cigar.

 

I have a heavily modified and recoded store I have been working on. I have spent a lot of time integrating and recoding the SPG Shipping Module into it. I love your work done on the Edit Orders contrib and have managed to modify it to work hand in hand with my separate shipping area.

 

Problem is I have a shipping table that is basically identical to the TABLE_ORDERS_PRODUCTS.

 

The codes I have duplicated in edit orders to update the shipping table all work perfect except for one table column in the shipping table which will not update with the proper orders_products_id. All other fields are updated correctly.

 

The main parts of the major players are: (forum won't post them neatly the way I typed them.)

 

TABLE_ORDERS_PRODUCTS:

 

Field Type Null Key Default Extra

orders_products_id int(11) PRI auto_increment

orders_id int(11) 0

products_id int(11) 0

 

 

TABLE_SPG_PRODUCTS_SHIPPING

 

Field Type Null Key Default Extra

spg_products_id int(11) PRI auto_increment

orders_id int(11) MUL 0

products_id int(11) YES MUL 0

orders_products_id int(11) MUL 0

 

 

 

I believe the code below from edit orders is where the problem needs custom coding to properly insert the identical orders_products_id into the shipping table. I know the proper way would be to make the two tables identical ... but I already have a ton of other files accessing the shipping table and would have to go through and rewrite them all if I changed it now.

 

Now I dont know if this is related to the problem but the orders_products_id is not auto_increment like it is in the orders table. Instead the spg_products_id is using the auto increment to keep track of independent shipping id's

 

I assume a new block of code will have to be added to edit orders to correctly relate the spg_products_id to the orders_products_id. I managed a few times to get a correct id into the field but was getting duplicate 1064 or whatever errors so took my code out.

 

 

 

Here is the section I believe needs tweaking. As you can see I have basically just duplicated the orders table insert and update queries to perform the same actions on the shipping table.

 

// Update orders_products Table

if (is_array($_POST['update_products'])) {

foreach($_POST['update_products'] as $orders_products_id => $products_details) {

if (!tep_not_null($products_details["qty"])) $products_details["qty"] = 0;

 

// 1.3.1.1 Update Inventory Quantity

$order_query = tep_db_query("select products_id, products_quantity from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$oID . "' and orders_products_id = '$orders_products_id'");

$order = tep_db_fetch_array($order_query);

 

// First we do a stock check

 

if ($products_details['qty'] != $order['products_quantity']) {

$different_quantity = ($products_details['qty'] - $order['products_quantity']);

if (STOCK_CHECK == 'true') {

tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = products_quantity - " . $different_quantity . ", products_ordered = products_ordered + " . $different_quantity . " where products_id = '" . (int)$order['products_id'] . "'");

 

} else {

tep_db_query("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . $different_quantity . " where products_id = '" . (int)$order['products_id'] . "'");

}

}

 

// Then we check if the product should be deleted

if (isset($products_details['delete'])) {

// update quantities first

if (STOCK_CHECK == 'true') {

tep_db_query("UPDATE " . TABLE_PRODUCTS . " SET

products_quantity = products_quantity + " . $products_details["qty"] . ",

products_ordered = products_ordered - " . $products_details["qty"] . "

WHERE products_id = '" . (int)$order['products_id'] . "'");

 

} else {

tep_db_query("UPDATE " . TABLE_PRODUCTS . " SET

products_ordered = products_ordered - " . $products_details["qty"] . "

WHERE products_id = '" . (int)$order['products_id'] . "'");

}

 

// then delete the little bugger

$Query = "delete from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$oID . "' and orders_products_id = '$orders_products_id';";

 

// added for shipping table

$QueryShipping = "delete from " . TABLE_SPG_PRODUCTS_SHIPPING . " where orders_id = '" . (int)$oID . "' and orders_products_id = '$orders_products_id';";

 

tep_db_query($Query);

tep_db_query($QueryShipping); // added for shipping table

 

// and all its attributes

if (isset($products_details['attributes'])) {

$Query = "delete from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$oID . "' and orders_products_id = '$orders_products_id';";

tep_db_query($Query);

 

/// BEGIN added for editing downloads

$Query2 = "delete from " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " where orders_id = '" . (int)$oID . "' and orders_products_id = '$orders_products_id';";

tep_db_query($Query2);

/// END added for editing downloads

 

}

 

} // end of if (isset($products_details['delete']))

 

else { // if we don't delete, we update

$Query = "UPDATE " . TABLE_ORDERS_PRODUCTS . " SET

products_model = '" . $products_details["model"] . "',

products_name = '" . tep_html_quotes($products_details["name"]) . "',

products_price = '" . $products_details["price"] . "',

final_price = '" . $products_details["final_price"] . "',

products_tax = '" . $products_details["tax"] . "',

products_quantity = '" . $products_details["qty"] . "'

WHERE orders_id = '" . (int)$oID . "'

AND orders_products_id = '$orders_products_id';";

 

// added for shipping table

$QueryShipping = "UPDATE " . TABLE_SPG_PRODUCTS_SHIPPING . " SET

products_name = '" . tep_html_quotes($products_details["name"]) . "',

products_price = '" . $products_details["price"] . "',

final_iprice = '" . $products_details["final_price"] . "',

products_tax = '" . $products_details["tax"] . "',

products_quantity = '" . $products_details["qty"] . "',

orders_products_id = '" . $orders_products_id . "'

WHERE orders_id = '" . (int)$oID . "'

AND orders_products_id = '$orders_products_id';";

 

tep_db_query($Query);

tep_db_query($QueryShipping); // added for shipping table

 

// update subtotal and total during update function

if (DISPLAY_PRICE_WITH_TAX == 'true') {

$RunningSubTotal += (($products_details['tax']/100 + 1) * ($products_details['qty'] * $products_details['final_price']));

} else {

$RunningSubTotal += $products_details['qty'] * $products_details['final_price'];

}

 

$RunningTax[$products_details['tax_description']] += (($products_details['tax']/100) * ($products_details['qty'] * $products_details['final_price']));

 

 

 

AND HERE is some sample code that does the updating from the shipping php file to the shipping table:

 

 

 

$index = 0;

$orders_products_query = tep_db_query("select p.orders_id, p.products_id, p.orders_products_id, p.products_quantity, p.products_price, p.final_price, q.products_cost, p.products_tax, p.products_name from " . TABLE_ORDERS_PRODUCTS . " p, " . TABLE_PRODUCTS . " q where p.products_id = q.products_id and p.orders_id = '" . (int)$_GET['oID'] . "'");

 

while ($orders_products = tep_db_fetch_array($orders_products_query)) {

$products_quantity = $orders_products['products_quantity'];

$products_price = $orders_products['final_price'];

$products_name = $orders_products['products_name'];

$products_tax = $orders_products['products_tax'];

$products_cost = $orders_products['products_cost'];

$orders_id = $orders_products['orders_id'];

$products_id = $orders_products['products_id'];

$orders_products_id = $orders_products['orders_products_id'];

 

tep_db_query("insert into " . TABLE_SPG_PRODUCTS_SHIPPING . " (spg_products_id, orders_id, products_id, orders_products_id, products_quantity, qty_shp, products_iprice, products_cost, final_iprice, products_tax, products_name) values ('', '" . (int)$_GET['oID'] . "', '" . $products_id . "', '" . $orders_products_id . "', '" . $products_quantity . "', '" . $products_quantity . "', '" . $products_price . "', '" . $products_cost . "', '" . $products_price . "', '" . $products_tax . "', '" . $products_name . "' )");

}

$index++;

}

 

 

Now your probably laughing and can see that it's probably something really stupid and simple.

 

Appreciate your input. Thanks a bunch!

Edited by insomniac2
Link to comment
Share on other sites

djmonkey1 .. you are the man. I was wondering if you had time to help me with a small problem that I have gotten so close .. but no cigar.

 

Thanks for the compliments! Unfortunately I'm not laughing and thinking it's simple, I'm wondering what it is you're trying to do. Based on what you've written your problem revolves around

 

				// added for shipping table
			$QueryShipping = "UPDATE " . TABLE_SPG_PRODUCTS_SHIPPING . " SET					
				products_name = '" . tep_html_quotes($products_details["name"]) . "',
				products_price = '" . $products_details["price"] . "',
				final_iprice = '" . $products_details["final_price"] . "',
				products_tax = '" . $products_details["tax"] . "',
				products_quantity = '" . $products_details["qty"] . "',
				orders_products_id = '" . $orders_products_id . "'
				WHERE orders_id = '" . (int)$oID . "'
				AND orders_products_id = '$orders_products_id';";

 

At first glance I don't see any problem with that query (the specific content of any errors you saw would help to identify if you have a comma out of place or something along those lines that is hard to see), but you stated that

The codes I have duplicated in edit orders to update the shipping table all work perfect except for one table column in the shipping table which will not update with the proper orders_products_id. All other fields are updated correctly.
which, to me, doesn't make sense, because the orders_products_id is one of the keys you're using in the query. When you tell a MySQL database to
UPDATE [some table] WHERE orders_id = '" . (int)$oID . "' AND orders_products_id = '$orders_products_id';"

you're not updating the orders_products_id at all, you're using it along with the orders_id to identify which row to update. If something goes haywire with the orders_products_id in this case you will either update nothing at all or maybe even the wrong row(s).

 

If it is a specific field that isn't being updated, which one is it?

 

Now, if the data doesn't exist at all (ie you're using Order Editor to import certain data into your new table), what you want to do is an INSERT, not an UPDATE.

 

Given that what you want to do is UPDATE pre-existing data, then the next step is to analyze the actual MySQL errors that you're getting. Very often these errors will tell you exactly where to look.

Do, or do not. There is no try.

 

Order Editor 5.0.6 "Ultra Violet" is now available!

For support or to post comments, suggestions, etc, please visit the Order Editor support thread.

Link to comment
Share on other sites

What it looks like OE is doing in this case is completely erasing the original entries for tax and replacing them with new ones (ie "Varav moms 6%" becomes just "moms 6%" after OE is used on the order). I've seen this before but the most recent versions shouldn't be having this problem. What version are you using?

I'm using v2.6.3, but how was this resolved earlier?

Also, for the FL tax business, it looks like you may have more than one tax class stored in the database. Look in your database under the table "tax_class" and see what the tax_class_id is for the tax class you most often use. Once you know that number you may have to edit the following at around line 24 of edit_orders.php

Absolutely correct! My two tax classes had id's of 3 and 4. Thanks for pointing that out. Brilliant!

 

/Magnus

Link to comment
Share on other sites

I'm using v2.6.3, but how was this resolved earlier?
There have been a number of improvements to the way Order Editor handles tax, the bulk coming around versions 2.4 and 2.5.
Absolutely correct! My two tax classes had id's of 3 and 4. Thanks for pointing that out. Brilliant!

 

/Magnus

Is it working correctly now? Or better at least?

Do, or do not. There is no try.

 

Order Editor 5.0.6 "Ultra Violet" is now available!

For support or to post comments, suggestions, etc, please visit the Order Editor support thread.

Link to comment
Share on other sites

Hi and thanks for the contrib 2.6.3. I have just installed it but seem to have the same problem as Stefan Lindvald. My invoice screen shows VAT as 20% of the total purchase price at the bottom row, just as desired:

order%20screen.JPG

 

But VAT becomes total purchase price in Order Editor:

orderscreen%20_in_order_editor.JPG

 

Here two screens of database table content (tax_class and tax_rate tables):

tax_class.JPG

tax_rates.JPG

 

The file catalog\includes\modules\order_total\ot_tax.php seems to be quite modified for Swedish VAT with the contribution "Swedish methods of payment 2.2" and if it helps I would be happy to post it here or parts of it here.

Link to comment
Share on other sites

There have been a number of improvements to the way Order Editor handles tax, the bulk coming around versions 2.4 and 2.5.

So, is there a way to make OE to not erase the original entries for tax and replace them with new ones?

 

Also, I looked a litte closer at the orders_total table and saw that the Value of 'total tax' is indeed the same as the total sum (inc. all), but the Text is showing the correct numbers (see pic.) Is this the case for you too, Gnarpjohan?

OE_DB1.png

Is it working correctly now? Or better at least?

Yes, the 'FL tax' is now included the way it should be. Thanks!!

 

/Magnus

Link to comment
Share on other sites

Also, I looked a litte closer at the orders_total table and saw that the Value of 'total tax' is indeed the same as the total sum (inc. all), but the Text is showing the correct numbers (see pic.) Is this the case for you too, Gnarpjohan?

 

Yes! It is the same for me. The text in orders_total is correct for "including VAT" but the value is wrong and is instead order total. I have a feeling that could be a very helpful observation from you. Thanks!

Link to comment
Share on other sites

So, is there a way to make OE to not erase the original entries for tax and replace them with new ones?
It's not supposed to erase anything unneccessarily- the purpose is not to rewrite the orders_total table every time you press update, but just to update it.
Also, I looked a litte closer at the orders_total table and saw that the Value of 'total tax' is indeed the same as the total sum (inc. all), but the Text is showing the correct numbers (see pic.) Is this the case for you too, Gnarpjohan?
This is very strange. I will look at this more and see if I can replicate these problems.

Do, or do not. There is no try.

 

Order Editor 5.0.6 "Ultra Violet" is now available!

For support or to post comments, suggestions, etc, please visit the Order Editor support thread.

Link to comment
Share on other sites

So, is there a way to make OE to not erase the original entries for tax and replace them with new ones?

 

Also, I looked a litte closer at the orders_total table and saw that the Value of 'total tax' is indeed the same as the total sum (inc. all), but the Text is showing the correct numbers (see pic.) Is this the case for you too, Gnarpjohan?

 

What is "Moms totalt"? Is that the total of all tax values from the order? What module creates this entry?

 

Also, please post screen shots for one order of both before and after editing with the Order Editor.

Edited by djmonkey1

Do, or do not. There is no try.

 

Order Editor 5.0.6 "Ultra Violet" is now available!

For support or to post comments, suggestions, etc, please visit the Order Editor support thread.

Link to comment
Share on other sites

What is "Moms totalt"? Is that the total of all tax values from the order? What module creates this entry?

 

Yes, "moms" totalt is the total value added tax, usually but not always 20% of the total sales value. My not so qualified guess is that it is specified in the modified catalog/includes/modules/order_total/ot_tax.php Apologies for this post:

 

<?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()) . "')");
}
}
?>

 

And in includes/languages/english/english/modules/order_total/ot_tax:

 

<?php
/*
Swedish Text for osCommerce 2.2
Last Update: 2003-03-03

 [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. 
*/

 define('MODULE_ORDER_TOTAL_TAX_HEADER', 'Swedish value added tax specification ');
 define('MODULE_ORDER_TOTAL_TAX_TITLE', 'Swedish value added tax');
 define('MODULE_ORDER_TOTAL_TAX_DESCRIPTION', 'Denna modul st?der att visa moms p? olika s?tt beroende p? om det ing?r eller ej i produktpriset');
 define('MODULE_ORDER_TOTAL_TAX_INCL_TITLE', 'Including VAT ');
 define('MODULE_ORDER_TOTAL_TAX_SPLIT_TITLE', 'Of which ');
?>

Link to comment
Share on other sites

Also, please post screen shots for one order of both before and after editing with the Order Editor.

 

Order details from the invoice after the unedited order of one product with 20% VAT (VAT=moms=merv?rdesskatt) of total value:

order%20screen.JPG

 

The same order details in Order Editor:

orderscreen%20_in_order_editor.JPG

"Fraktkostnad" is cost of shipping which also includes 20% VAT. (Yes, I should fix the language)

 

Here I add one identical product from Order Editor and update:

order_screen_after_a_new_product.JPG

 

The funny thing is that the VAT is now computed correctly. But on another line (not the bottom line as before but before the shipping cost). Order total before shipping of 40 includes VAT and so does shipping cost ("fraktkostnad") of 25. So the total order value is 40+25=65 of which VAT should be 20% or 65*0.2=13, correct!

 

My Order Total Modules setting in admin is still to display VAT at the bottom row.

 

Thanks for even looking at this stuff...

Edited by Gnarpjohan
Link to comment
Share on other sites

After deleting the added product, I get:

order_screen_after_deleting_new_product.JPG

 

...which again is the original order with VAT computed correctly but not displayed at the bottom row which would be the best. The order of the display is the same for the invoice as well.

Link to comment
Share on other sites

Order details from the invoice after the unedited order of one product with 20% VAT (VAT=moms=merv?rdesskatt) of total value:

 

 

The same order details in Order Editor:

 

"Fraktkostnad" is cost of shipping which also includes 20% VAT. (Yes, I should fix the language)

 

Here I add one identical product from Order Editor and update:

 

 

The funny thing is that the VAT is now computed correctly. But on another line (not the bottom line as before but before the shipping cost). Order total before shipping of 40 includes VAT and so does shipping cost ("fraktkostnad") of 25. So the total order value is 40+25=65 of which VAT should be 20% or 65*0.2=13, correct!

 

My Order Total Modules setting in admin is still to display VAT at the bottom row.

 

Thanks for even looking at this stuff...

 

Based on these screen shots, the problem of showing 45.00 for the total tax doesn't lie with Order Editor but with your custom tax module, because that's how the value is being stored in the database when the customer checks out. The tax module or whatever it is in your checkout process that is doing this should be adjusted to store the value of this total component properly.

 

The problem of Order Editor re-writing the tax component lies with the fact you have the tax description saved in your database as "Merv?rdesskatt" but your tax module writes it as "Including VAT". When Order Editor calculates the tax total(s) of your order (every time you press "update" or add a product), it's looking for "Merv?rdesskatt". When it doesn't find that tax component, it writes it in and deletes the other entry.

 

To continue using Order Editor and not have this problem, you can :

 

1. Go into the language include for your ot_tax module and change

define('MODULE_ORDER_TOTAL_TAX_INCL_TITLE', 'Including VAT ');

to

define('MODULE_ORDER_TOTAL_TAX_INCL_TITLE', 'Merv?rdesskatt ');

 

or,

 

2. In your shop admin tool, change the tax description "Merv?rdesskatt" to "Including VAT".

 

If for some reason neither of these options is possible, you would have to custom modify Order Editor to work with your shop.

Edited by djmonkey1

Do, or do not. There is no try.

 

Order Editor 5.0.6 "Ultra Violet" is now available!

For support or to post comments, suggestions, etc, please visit the Order Editor support thread.

Link to comment
Share on other sites

Hi Stew,

 

I've added "AdminComments Toolbar" to my edit_orders.php but there is a little problem. When I click any button to place comments, they are added to my product's description field instead of comments field. All that the contribution requires to change in admin/edit_orders.php is:

After:

 

if($CommentsWithStatus) {

echo tep_draw_textarea_field('comments', 'soft', '40', '5');

} else {

echo tep_draw_textarea_field('comments', 'soft', '40', '5', $order->info['comments']);

}

?>

</td>

</tr>

</table>

 

Insert this:

 

<!-- Comment Toolbar 4.0 bof //-->

<tr>

<td><?php include ("comment_bar.php"); ?></td>

</tr>

<!-- Comment Toolbar 4.0 eof //-->

This is exactly what I did. Could you please help me with this?

 

Thanks in advance.

Link to comment
Share on other sites

Just when I thought I'd found every "must have" great contibution I found this!

 

Thanks to all the contributors, great job!!

Edited by thunderace
Link to comment
Share on other sites

Hi Stew,

 

I've added "AdminComments Toolbar" to my edit_orders.php but there is a little problem. When I click any button to place comments, they are added to my product's description field instead of comments field. All that the contribution requires to change in admin/edit_orders.php is:

 

This is exactly what I did. Could you please help me with this?

 

Thanks in advance.

 

Beats me- I tried it out and didn't have a problem. You're using v2.6.3 of Order Editor and v4.0 of Admin Comments Toolbar, right?

Do, or do not. There is no try.

 

Order Editor 5.0.6 "Ultra Violet" is now available!

For support or to post comments, suggestions, etc, please visit the Order Editor support thread.

Link to comment
Share on other sites

Beats me- I tried it out and didn't have a problem. You're using v2.6.3 of Order Editor and v4.0 of Admin Comments Toolbar, right?

Yes, I do and I also have a GOOGIESPELL added. So, here is what I have for the comments:

<td class="main" width="10">?</td>

<td class="main">

<!-- GOOGIESPELL BEGIN -->

<?php echo tep_draw_textarea_field('comments', 'soft', '40', '5', '', 'id="tal" class="textarea"'); ?>

 

<script type="text/javascript">

var googie1 = new GoogieSpell("googiespell/", "googiespell/sendReq2.php?lang=");

googie1.decorateTextarea("tal");

</script>

<!-- GOOGIESPELL END -->

</td>

</tr>

</table>

<!-- Comment Toolbar 4.0 bof //-->

<tr>

<td><?php include ("comment_bar.php"); ?></td>

</tr>

<!-- Comment Toolbar 4.0 eof //-->

</td>

</tr>

Thanks.

Link to comment
Share on other sites

Yes, I do and I also have a GOOGIESPELL added. So, here is what I have for the comments:

 

Thanks.

 

Well, I can't see any compatibility issues here. If you give me a step-by-step rundown of how things work with the comment bar add-on, as far as what you do, what happens next, etc, maybe I can think of something.

Do, or do not. There is no try.

 

Order Editor 5.0.6 "Ultra Violet" is now available!

For support or to post comments, suggestions, etc, please visit the Order Editor support thread.

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