Jump to content
jhilgeman

NEW! Complete Order Editing Tool!

Recommended Posts

Thanks for contribution ver. 3_0_1, easy to install and use.

Meanwhile I noted a bug.

I use contribution "Subtotal excl vat" in Modules - Order total

http://www.oscommerce.com/community/contributions,4618

 

On Edit order page the line "Subtotal excl vat" appears in part 3 - Discount, Shipping and Total.

First of all the field "ammont" has wrong value, actually it has subtotal included vat and not excluded.

By manual edit this field the calculation of Total is wrong and shows as Total = Subtotal excl vat + vat + Sub total + Shipping

 

Any way to solve the problem?

 

Thanks

Sergei

 

It's not really a bug, it's just that you have a custom subtotal component and so will need to customize Order Editor to work with your store.

 

Post the class value of the "Subtotal excl vat" as stored in the orders_total table. It should be something like ot_subtotal_ht or something like that.


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.

Share this post


Link to post
Share on other sites
Disable the payment method dropdown.

 

Thanks, that did the trick. Is there something I can do to reenable it or will I always have that dropown disabled now?

 

Anthony

Edited by analli

Share this post


Link to post
Share on other sites
Thanks, that did the trick. Is there something I can do to reenable it or will I always have that dropown disabled now?

 

Anthony

 

The problem seems to be in freeofcharge.php, specifically the following lines of code:

 

// disable the module if the order only contains virtual products
	 if ($this->enabled == true) {
	   global $cart;
	   if ($cart->show_total() >= 0.01) {
		 $this->enabled = false;
	   }
	 }

 

You could try something like

// disable the module if the order only contains virtual products
	   if ( ($this->enabled == true) && (isset($cart)) ){
		 global $cart;
		 if ($cart->show_total() >= 0.01) {
		   $this->enabled = false;
		 }
	   }

 

instead, and see if that will still allow the module to function on the catalog side while preventing the error from the payment method dropdown in 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.

Share this post


Link to post
Share on other sites
Thanks, that did the trick. Is there something I can do to reenable it or will I always have that dropown disabled now?

 

Anthony

 

If the post above doesn't work you could also try

 

// disable the module if the order only contains virtual products
	   if ( ($this->enabled == true) && (is_object($cart)) ){
		 global $cart;
		 if ($cart->show_total() >= 0.01) {
		   $this->enabled = false;
		 }
	   }


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.

Share this post


Link to post
Share on other sites
If the post above doesn't work you could also try

 

// disable the module if the order only contains virtual products
	   if ( ($this->enabled == true) && (is_object($cart)) ){
		 global $cart;
		 if ($cart->show_total() >= 0.01) {
		   $this->enabled = false;
		 }
	   }

 

 

Both of the above edits restore the normal function of Order Editor with the drop down. Unfortunately, a feature of the freeofcharge module is that if the cart has a value of 1 cent or greater freeofcharge is excluded from the payment list. With either one of these edits in place freeofcharge ALWAYS appears as a payment option regardless of cart value.

 

No biggie. The dropdown is not at all critical to me. I thought you might like a follow up.

 

Anthony

Share this post


Link to post
Share on other sites
It's not really a bug, it's just that you have a custom subtotal component and so will need to customize Order Editor to work with your store.

 

Post the class value of the "Subtotal excl vat" as stored in the orders_total table. It should be something like ot_subtotal_ht or something like that.

 

Hi Stew

 

Thanks for response,

 

It is ot_subtotal_ex

I found it by phpMyAdmin -> orders_total -> row: value -> column -> class

 

Hope it is that needed

 

I would very appreciated for customization because I actually can't use the contribution although it is

perfectly suitable and already installed.

 

Thanks

Sergei

Share this post


Link to post
Share on other sites
Both of the above edits restore the normal function of Order Editor with the drop down. Unfortunately, a feature of the freeofcharge module is that if the cart has a value of 1 cent or greater freeofcharge is excluded from the payment list. With either one of these edits in place freeofcharge ALWAYS appears as a payment option regardless of cart value.

 

No biggie. The dropdown is not at all critical to me. I thought you might like a follow up.

 

Anthony

 

There's more than one way to skin a cat- try changing

// class methods
 function update_status() {
   global $order;

// disable the module if the order only contains virtual products
   if ($this->enabled == true) {
	 global $cart;
	 if ($cart->show_total() >= 0.01) {
	   $this->enabled = false;
	 }
   }
 }

to

// class methods
 function update_status() {
   global $order;

// disable the module if the order only contains virtual products
   if ($this->enabled == true) {
	 global $cart;
	   if (is_object($cart)) {
		if ($cart->show_total() >= 0.01) {
		$this->enabled = false;
	   }
	 }
   }
 }


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.

Share this post


Link to post
Share on other sites
Hi Stew

 

Thanks for response,

 

It is ot_subtotal_ex

I found it by phpMyAdmin -> orders_total -> row: value -> column -> class

 

Hope it is that needed

 

I would very appreciated for customization because I actually can't use the contribution although it is

perfectly suitable and already installed.

 

Thanks

Sergei

 

In admin/edit_orders.php change

	// 1.3 UPDATE PRODUCTS #####
		 $RunningSubTotal = 0;
		 $RunningTax = array($default_tax_name => 0);

to

	// 1.3 UPDATE PRODUCTS #####
		 $RunningSubTotal = 0;
		 $RunningSubTotal_EX = 0;
		 $RunningTax = array($default_tax_name => 0);

 

Then change

				  //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"];
				 }

to

 

				  //update subtotal and total during update function

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

			 $RunningSubTotal_EX += $products_details["qty"] * $products_details["final_price"];

 

Then change

					if ($ot_class == "ot_subtotal") {
						 $ot_value = $RunningSubTotal;
					 }	

					 if ($ot_class == "ot_tax") {
						 $ot_value = $RunningTax[preg_replace("/:$/","",$ot_title)];
					 }

to

					if ($ot_class == "ot_subtotal") {
						 $ot_value = $RunningSubTotal;
					 }	

					 if ($ot_class == "ot_subtotal_ex") {
						   $ot_value = $RunningSubTotal_EX;
					   }	

					 if ($ot_class == "ot_tax") {
						 $ot_value = $RunningTax[preg_replace("/:$/","",$ot_title)];
					 }

 

Then change

	if (!trim($ot_value) && ($ot_class != "ot_shipping") && ($ot_class != "ot_subtotal") && ($ot_class != "ot_total")) { // value = 0 => Delete Total Piece

to

	if (!trim($ot_value) && ($ot_class != "ot_shipping") && ($ot_class != "ot_subtotal_ex") && ($ot_class != "ot_subtotal") && ($ot_class != "ot_total")) { // value = 0 => Delete Total Piece

 

Then change

			// 2.2.2 Calculate Tax and Sub-Totals
		   $order = new oe_order($oID);
		   $RunningSubTotal = 0;
		   $RunningTax = array($default_tax_name => 0);

to

			// 2.2.2 Calculate Tax and Sub-Totals
		   $order = new oe_order($oID);
		   $RunningSubTotal = 0;
		   $RunningSubTotal_EX = 0;
		   $RunningTax = array($default_tax_name => 0);

 

Then change

		// This calculatiion of Subtotal and Tax is part of the 'add a product' process
	   if (DISPLAY_PRICE_WITH_TAX == 'true') {
   $RunningSubTotal += (($order->products[$i]['tax'] / 100 + 1) * ($order->products[$i]['qty'] * $order->products[$i]['final_price']));
	   } else {
   $RunningSubTotal += ($order->products[$i]['qty'] * $order->products[$i]['final_price']);
	   }

to

		// This calculation of Subtotal and Tax is part of the 'add a product' process

   $RunningSubTotal += (($order->products[$i]['tax'] / 100 + 1) * ($order->products[$i]['qty'] * $order->products[$i]['final_price']));

   $RunningSubTotal_EX += ($order->products[$i]['qty'] * $order->products[$i]['final_price']);

 

Then change

			// 2.2.2.2 Sub-Total
		   $Query = 'UPDATE ' . TABLE_ORDERS_TOTAL . ' SET
			   text = "' . $currencies->format($RunningSubTotal, true, $order->info['currency'], $order->info['currency_value']) . '",
			   value = "' . $RunningSubTotal . '"
			   WHERE class="ot_subtotal" 
			   AND orders_id= "' . (int)$oID . '"';
		   tep_db_query($Query);

		   // 2.2.2.3 Total
		   if (DISPLAY_PRICE_WITH_TAX == 'true') {
		   $Query = 'SELECT sum(value) 
		   AS total_value from ' . TABLE_ORDERS_TOTAL . '
		   WHERE class != "ot_total" 
		   AND class != "ot_tax" 
		   AND orders_id= "' . (int)$oID . '"';
		   $result = tep_db_query($Query);
		   $row = tep_db_fetch_array($result);
		   $Total = $row['total_value'];
		   } else {
		   $Query = 'SELECT sum(value) 
		   AS total_value from ' . TABLE_ORDERS_TOTAL . '
		   WHERE class != "ot_total" 
		   AND orders_id= "' . (int)$oID . '"';
		   $result = tep_db_query($Query);
		   $row = tep_db_fetch_array($result);
		   $Total = $row['total_value'];
		   }

to

			// 2.2.2.2 Sub-Total
		   $Query = 'UPDATE ' . TABLE_ORDERS_TOTAL . ' SET
			   text = "' . $currencies->format($RunningSubTotal, true, $order->info['currency'], $order->info['currency_value']) . '",
			   value = "' . $RunningSubTotal . '"
			   WHERE class="ot_subtotal" 
			   AND orders_id= "' . (int)$oID . '"';
		   tep_db_query($Query);

		   // 2.2.2.3 Sub-Total_EX
			 $Query2 = 'UPDATE ' . TABLE_ORDERS_TOTAL . ' SET
				 text = "' . $currencies->format($RunningSubTotal_EX,  true, $order->info['currency'], $order->info['currency_value']) .  '",
				 value = "' . $RunningSubTotal_EX . '"
				 WHERE class="ot_subtotal_ex" 
				 AND orders_id= "' . (int)$oID . '"';
			 tep_db_query($Query2);

		   // 2.2.2.3 Total
		   if (DISPLAY_PRICE_WITH_TAX == 'true') {
		   $Query = 'SELECT sum(value) 
		   AS total_value from ' . TABLE_ORDERS_TOTAL . '
		   WHERE class != "ot_total" 
		   AND class != "ot_subtotal_ex" 
		   AND class != "ot_tax" 
		   AND orders_id= "' . (int)$oID . '"';
		   $result = tep_db_query($Query);
		   $row = tep_db_fetch_array($result);
		   $Total = $row['total_value'];
		   } else {
		   $Query = 'SELECT sum(value) 
		   AS total_value from ' . TABLE_ORDERS_TOTAL . '
		   WHERE class != "ot_total" 
		   AND class != "ot_subtotal_ex" 
		   AND orders_id= "' . (int)$oID . '"';
		   $result = tep_db_query($Query);
		   $row = tep_db_fetch_array($result);
		   $Total = $row['total_value'];
		   }

and see how it works then.


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.

Share this post


Link to post
Share on other sites

Hi Stew,

 

Thanks for the modifications but I'm sorry to say that it still has a wrong calculation sometimes. I sent PM with 5 screenshots and the comments.

Also it supply wrong calculations for invoice.php and email_invoice

 

That do you think about? Any way to solve or it is too complicated?

 

Sergei

Share this post


Link to post
Share on other sites
Hi Stew,

 

Thanks for the modifications but I'm sorry to say that it still has a wrong calculation sometimes. I sent PM with 5 screenshots and the comments.

Also it supply wrong calculations for invoice.php and email_invoice

 

That do you think about? Any way to solve or it is too complicated?

 

Sergei

 

<edited> I will look at this more and get back to you.

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.

Share this post


Link to post
Share on other sites
Hi Stew,

 

Thanks for the modifications but I'm sorry to say that it still has a wrong calculation sometimes. I sent PM with 5 screenshots and the comments.

Also it supply wrong calculations for invoice.php and email_invoice

 

That do you think about? Any way to solve or it is too complicated?

 

Sergei

 

First thing, find in admin/edit_orders.php

		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")
	{

and change it to

		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_subtotal_ex" ||
	$TotalDetails["Class"] == "ot_tax")
	{


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.

Share this post


Link to post
Share on other sites

Hi,

 

I'm still using version 2.8.2 of Edit Order.

 

My problem is that for one particular invoice, an entry is always made with class 'ot_tax'. I've browsed through the code and found that a search is done to find out if an entry of 'ot_tax' class already exists. If not, an entry is made automatically. However, in my situation, that entry does exist already but the new entry is made anyway.

 

Perhaps my title does not match the regular expression used in:

(preg_replace("/:$/","",$ot_title) == $key))

 

I have no knowledge of regular expressions so I wouldn't know. And I'm not sure what is supposed to happen in this line.

 

My title is:

Incl. 19% BTW:

 

 

Is this the problem? Or does anyone else know why this happens? I have searched this forum but couldn't find the answer.

 

Thanks!

 

Eugene

Share this post


Link to post
Share on other sites
My problem is that for one particular invoice, an entry is always made with class 'ot_tax'. I've browsed through the code and found that a search is done to find out if an entry of 'ot_tax' class already exists. If not, an entry is made automatically. However, in my situation, that entry does exist already but the new entry is made anyway.

 

I meant an entry in the orders_total table. Which results in specifying the VAT amount twice. And I browsed through the file edit_orders.php

Share this post


Link to post
Share on other sites
I meant an entry in the orders_total table. Which results in specifying the VAT amount twice. And I browsed through the file edit_orders.php

 

Is this happening only on a particular invoice, as you said in your first post, or on every invoice that has Incl. 19% BTW:?

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.

Share this post


Link to post
Share on other sites

Hi Stew,

 

Thanks for improvement.

Now Sub-total ex. field in #3. Discount, Shipping and Total table has correct figure w/o VAT on the Edit page open. This field is no more editable on the page. If to edit Shipping price on the page then the Total field is recalculating correctly but after Update button hit it again get a wrong sum.

 

Sergei

 

First thing, find in admin/edit_orders.php
		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")
	{

and change it to

		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_subtotal_ex" ||
	$TotalDetails["Class"] == "ot_tax")
	{

Share this post


Link to post
Share on other sites
Hi Stew,

 

Thanks for improvement.

Now Sub-total ex. field in #3. Discount, Shipping and Total table has correct figure w/o VAT on the Edit page open. This field is no more editable on the page. If to edit Shipping price on the page then the Total field is recalculating correctly but after Update button hit it again get a wrong sum.

 

Sergei

 

Please be more specific as to how it's wrong after you hit the update button. Please list an example showing what the totals should be after update and what they actually are.


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.

Share this post


Link to post
Share on other sites

here is a shot

edit5_second_edit_updated.jpg

 

Please be more specific as to how it's wrong after you hit the update button. Please list an example showing what the totals should be after update and what they actually are.

Share this post


Link to post
Share on other sites
here is a shot

Find in admin/edit_orders.php

					if ($ot_class == "ot_tax") {

				   if (DISPLAY_PRICE_WITH_TAX != 'true') { 
				   //we don't add tax to the total here because it's already added to the subtotal
					   $RunningTotal += $ot_value;
					   }
					   } else {
					   $RunningTotal += $ot_value;
					   }

and change it to

					if ($ot_class == "ot_tax") {

				   if (DISPLAY_PRICE_WITH_TAX != 'true') { 
				   //we don't add tax to the total here because it's already added to the subtotal
					   $RunningTotal += $ot_value;
					   }
					   } elseif ($ot_class != "ot_subtotal_ex") {
					   $RunningTotal += $ot_value;
					   }


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.

Share this post


Link to post
Share on other sites
How to change order ID number ?

 

Thx, renu:x

 

That's not something I would advise doing. Besides being stored in the orders table, the orders_id is used as a key for information stored in orders_products, orders_products_attributes, orders_products_download, orders_status_history, and orders_total, so if you change it in one or any of those tables you lose the relationship to the data stored in the other tables. For that matter, if you were to try to write a SQL command to change the orders_id, what key would you use to determine which one to change? The orders_id itself is the key that is always used in updating the information in these tables.

 

Why would you want to change the order ID number?


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.

Share this post


Link to post
Share on other sites
Is this happening only on a particular invoice, as you said in your first post, or on every invoice that has Incl. 19% BTW:?

 

Hi, thanks for your quick response.

 

I did some testing, and it seems to be happening for one particular invoice only. By the way, the 'incl.19% BTW:' is on every invoice. So I'm a bit puzzled.

 

There were some problems related to the faulty invoice. The shop owner deleted some products that were listed on the invoice and that caused some trouble. But I don't know if this has to do with the problem I described.

 

If anyone has a clue where I should look, I'll be happy to know. And otherwise, I just leave it until it pops up again.

 

Thanks!

 

Eugene

Share this post


Link to post
Share on other sites
Hi, thanks for your quick response.

 

I did some testing, and it seems to be happening for one particular invoice only. By the way, the 'incl.19% BTW:' is on every invoice. So I'm a bit puzzled.

 

There were some problems related to the faulty invoice. The shop owner deleted some products that were listed on the invoice and that caused some trouble. But I don't know if this has to do with the problem I described.

 

If anyone has a clue where I should look, I'll be happy to know. And otherwise, I just leave it until it pops up again.

 

Thanks!

 

Eugene

 

Can you just delete the extra tax component from the database manually?


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.

Share this post


Link to post
Share on other sites

Hi Stew,

 

It works!!!!

It fully functional and has no any problem, I'm very appreciated for your attention and support!

I suggest this improvement can be helpful for all as a version of the contribution.

 

All the best

 

Sergei

 

Find in admin/edit_orders.php
					if ($ot_class == "ot_tax") {

......

Share this post


Link to post
Share on other sites
Can you just delete the extra tax component from the database manually?

 

I can. But if I do any modification (or just press the update button without really changing anything) it comes back again. That's why I looked for the code where the entry is made.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×