Jump to content
jhilgeman

NEW! Complete Order Editing Tool!

Recommended Posts

Hello @ all,

 

this is a very fine release for osCommerce (Order Editor 2.5.4).

 

I have one problem with it:

 

If i edit an order and add new products ore change products the includet tax is shown twice.

1. Tax of the original order

2. Tax of the new included products ore changes

 

Database example of orders_total:

 

59 Tax1: 94,18? 94.1761 ot_tax 1

59 Total: 707,82? 707.8168 ot_total 5

59 Subtotal: 697,82? 697.8168 ot_subtotal 2

59 Shipping: 10,00? 10.0000 ot_shipping 3

59 Tax2: 1,04? 1.0400 ot_tax 4

 

I would like that changes on Products automaticaly change the entry of the included tax field. also if the taxrates are different.

 

How can i fix that problem?

 

best regards networkjunkie

Share this post


Link to post
Share on other sites
Hello @ all,

 

this is a very fine release for osCommerce (Order Editor 2.5.4).

 

I have one problem with it:

 

If i edit an order and add new products ore change products the includet tax is shown twice.

1. Tax of the original order

2. Tax of the new included products ore changes

 

Database example of orders_total:

 

59 Tax1: 94,18? 94.1761 ot_tax 1

59 Total: 707,82? 707.8168 ot_total 5

59 Subtotal: 697,82? 697.8168 ot_subtotal 2

59 Shipping: 10,00? 10.0000 ot_shipping 3

59 Tax2: 1,04? 1.0400 ot_tax 4

 

I would like that changes on Products automaticaly change the entry of the included tax field. also if the taxrates are different.

 

How can i fix that problem?

 

best regards networkjunkie

 

I have found my problem.

It was the shipping tax.

 

but how is it possible to update the taxfield (ot_tax) after adding an product?

 

best regards

Share this post


Link to post
Share on other sites

Hello again,

 

i have now tried some things and i am getting nearly to an perfect state.

 

2 more questions.

 

1. How is it possible, after adding an product, the tax (configured in Tax Classes) is updating automatically. It sould work like pressing the updating button. I am not very into PHP so i cant find the right code to copy from 1. UPDATE ORDER to 2. ADD A PRODUCT to get this thing work.

 

2. How is it possible to give the orders_total table an other order. I would like to have it like this:

 

- Subtotal

- Tax 1 (configured in Tax Classes)

- Tax 2 (configured in Tax Classes)

...

 

- Shipping Costs

- Tax Shipping Costs (Tax entry from edit_orders.php / ENTRY_TAX)

 

- Total

 

best regards

Share this post


Link to post
Share on other sites

This is a great contribution. I have just installed and it is working great. My only problem is I am getting an error.

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/xxx/www/www/catalog/admin/includes/functions/general.php:1375) in /home/xxx/www/www/catalog/admin/includes/functions/sessions.php on line 67

 

This seems to be on everypage in my admin section. It doesn't seem to affect the functionality but is very annoying and it does seem to prevent some pages from redirecting correctly after updateing an order.

 

Here is some code from around line 67 in sessions.php (which I am wondering why this would be the issue

since I havn't modified this file)

 

66 function tep_session_start() {

67 return session_start();

68 }

 

Line 1375 of general.php is the end of the file so I am a little perplexed.

 

Has anyone seen this in regards to this contribution?

Thanks in advance,

Blaine

Share this post


Link to post
Share on other sites
This is a great contribution. I have just installed and it is working great. My only problem is I am getting an error.

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/xxx/www/www/catalog/admin/includes/functions/general.php:1375) in /home/xxx/www/www/catalog/admin/includes/functions/sessions.php on line 67

 

This seems to be on everypage in my admin section. It doesn't seem to affect the functionality but is very annoying and it does seem to prevent some pages from redirecting correctly after updateing an order.

 

Here is some code from around line 67 in sessions.php (which I am wondering why this would be the issue

since I havn't modified this file)

 

66 function tep_session_start() {

67 return session_start();

68 }

 

Line 1375 of general.php is the end of the file so I am a little perplexed.

 

Has anyone seen this in regards to this contribution?

Thanks in advance,

Blaine

 

Never mind, I found it in another post on this topic. Deleted the extra lines at the end of general.php and now it is perfect. Thanks,

Share this post


Link to post
Share on other sites
djmonkey1,

I already tried those changes and it did not work for me. I think it might be because the class for my coupons is ot_coupon, whereas Svenja's discounts are being applied as ot_payment. Any ideas?

 

I also want to give my appreciation to you for going above and beyond in the level of support you provide on these boards. Thanks!

 

regards,

v

 

Yes- you need to find every instance of "ot_payment" in the code and change it to "ot_coupon".


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
1. How is it possible, after adding an product, the tax (configured in Tax Classes) is updating automatically. It sould work like pressing the updating button. I am not very into PHP so i cant find the right code to copy from 1. UPDATE ORDER to 2. ADD A PRODUCT to get this thing work.

This is one of those problems that, no matter how many times I think I've fixed it, keeps popping up.

 

Find at about line 563:

//just adding in shipping tax, don't mind me
	$ot_shipping_query = tep_db_query("
	SELECT class, value 
	FROM " . TABLE_ORDERS_TOTAL . " 
	WHERE orders_id = '" . (int)$oID . "'");
	$ot_shipping_value = tep_db_fetch_array($ot_shipping_query);


if ($ot_shipping_value['class'] == 'ot_shipping')//a good place to add in other fields to tax
	{
	if (DISPLAY_PRICE_WITH_TAX == 'true') {
		$RunningTax[$default_tax_name] += ($ot_shipping_value['value'] * $order->info['shipping_tax'] / ($order->info['shipping_tax'] + 100));
			} else {
		$RunningTax[$default_tax_name] += (($order->info['shipping_tax'] / 100) * $ot_shipping_value['value']);

				}// end if (DISPLAY_PRICE_WITH_TAX == 'true') {
				}// end if ($ot_shipping_value['class'] == 'ot_shipping')

	// end shipping tax calcs

and change it to

  //just adding in shipping tax, don't mind me
	$ot_shipping_query = tep_db_query("
	SELECT value 
	FROM " . TABLE_ORDERS_TOTAL . " 
	WHERE orders_id = '" . (int)$oID . "'
	AND class = 'ot_shipping'");

	while ($ot_shipping_info = tep_db_fetch_array($ot_shipping_query)) {
	  $ot_shipping_value = $ot_shipping_info['value'];
	}// end while

	if (DISPLAY_PRICE_WITH_TAX == 'true') {
		$RunningTax[$default_tax_name] += ($ot_shipping_value * $order->info['shipping_tax'] / ($order->info['shipping_tax'] + 100));
			} else {
 $RunningTax[$default_tax_name] += (($order->info['shipping_tax'] / 100) * $ot_shipping_value);

				}// end if (DISPLAY_PRICE_WITH_TAX == 'true') {

	// end shipping tax calcs

 

Then find at about line 598:

// 2.2.2.1 Tax
	foreach ($RunningTax as $key => $val) {
		$Query = 'UPDATE ' . TABLE_ORDERS_TOTAL . ' set
		text = "' . $currencies->format($val, true, $order->info['currency'], $order->info['currency_value']) . '",
		value = "' . $val . '"
		WHERE class= "ot_tax" 
		AND title = "' . $key . '" 
		AND orders_id= "' . (int)$oID . '"';
		tep_db_query($Query);
		}

and change it to

// 2.2.2.1 Tax
	foreach ($RunningTax as $key => $val) {
		$Query = 'UPDATE ' . TABLE_ORDERS_TOTAL . ' set
		text = "' . $currencies->format($val, true, $order->info['currency'], $order->info['currency_value']) . '",
		value = "' . $val . '"
		WHERE class= "ot_tax" 
		AND (title = "' . $key . ':" OR title = "' . $key . '")
		AND orders_id= "' . (int)$oID . '"';
		tep_db_query($Query);
		}

 

and let me know how that goes.


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 you read Svenja K's post, you will see an example of someone with an almost identical problem. Read through the various followup responses and you will find step by step instructions on how to adjust for a discount value of this sort. If you don't want to assess tax on your discount then you would not perform the changes prescribed at lines 263, 563, 956, and 1008.

 

djmonkey,

thanks again for your support!!! i have the negative discount probelm solved. now, one more thing...

 

i left out the changes you prescribed to svenja (lines 263, 563, 956 and 1008), however, i'm still getting a taxed amount that is pre-discount. for example, i live in los angeles and our tax rate is 8.25%. i sell a product that's $100 - $25 discount. The tax that is being charged is $8.25 and not $6.19 as it should be. is there something else that needs to be done?

 

thanks,

v

Share this post


Link to post
Share on other sites
djmonkey,

thanks again for your support!!! i have the negative discount probelm solved. now, one more thing...

 

i left out the changes you prescribed to svenja (lines 263, 563, 956 and 1008), however, i'm still getting a taxed amount that is pre-discount. for example, i live in los angeles and our tax rate is 8.25%. i sell a product that's $100 - $25 discount. The tax that is being charged is $8.25 and not $6.19 as it should be. is there something else that needs to be done?

 

thanks,

v

 

You need to perform the changes at lines 263, 563, 956, and 1008, except that at line 563 you should find:

 

//just adding in shipping tax, don't mind me
	$ot_shipping_query = tep_db_query("
	SELECT class, value 
	FROM " . TABLE_ORDERS_TOTAL . " 
	WHERE orders_id = '" . (int)$oID . "'");
	$ot_shipping_value = tep_db_fetch_array($ot_shipping_query);


if ($ot_shipping_value['class'] == 'ot_shipping')//a good place to add in other fields to tax
	{
	if (DISPLAY_PRICE_WITH_TAX == 'true') {
		$RunningTax[$default_tax_name]  += ($ot_shipping_value['value'] * $order->info['shipping_tax'] /  ($order->info['shipping_tax'] + 100));
			} else {
		$RunningTax[$default_tax_name] += (($order->info['shipping_tax'] / 100) * $ot_shipping_value['value']);

				}// end if (DISPLAY_PRICE_WITH_TAX == 'true') {
				}// end if ($ot_shipping_value['class'] == 'ot_shipping')

	// end shipping tax calcs

 

and change it to

 

//just adding in shipping tax, don't mind me
	$ot_shipping_query = tep_db_query("
	SELECT value 
	FROM " . TABLE_ORDERS_TOTAL . " 
	WHERE orders_id = '" . (int)$oID . "'
	AND class = 'ot_shipping'");

	while ($ot_shipping_info = tep_db_fetch_array($ot_shipping_query)) {
	  $ot_shipping_value = $ot_shipping_info['value'];

	if (DISPLAY_PRICE_WITH_TAX == 'true') {
		$RunningTax[$default_tax_name]  += ($ot_shipping_value * $order->info['shipping_tax'] /  ($order->info['shipping_tax'] + 100));
			} else {
 $RunningTax[$default_tax_name] += (($order->info['shipping_tax'] / 100) * $ot_shipping_value);

				}// end if (DISPLAY_PRICE_WITH_TAX == 'true') {
  }// end while

	// end shipping tax calcs

//just taking out discount tax, don't mind me
	$ot_coupon_query = tep_db_query("
	SELECT value 
	FROM " . TABLE_ORDERS_TOTAL . " 
	WHERE orders_id = '" . (int)$oID . "'
	AND class = 'ot_coupon'");

	while ($ot_coupon_info = tep_db_fetch_array($ot_coupon_query)) {
	  $ot_coupon_value = $ot_coupon_info['value'];

	if (DISPLAY_PRICE_WITH_TAX == 'true') {
		$RunningTax[$default_tax_name] -= ($ot_coupon_value * $order->info['shipping_tax'] /  ($order->info['shipping_tax'] + 100));
			} else {
 $RunningTax[$default_tax_name] -= (($order->info['shipping_tax'] / 100) * $ot_coupon_value);

				}// end if (DISPLAY_PRICE_WITH_TAX == 'true') {
   }// end while

	// end discount tax calcs


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
You need to perform the changes at lines 263, 563, 956, and 1008, except that at line 563 you should find:

 

//just adding in shipping tax, don't mind me
	$ot_shipping_query = tep_db_query("
	SELECT class, value 
	FROM " . TABLE_ORDERS_TOTAL . " 
	WHERE orders_id = '" . (int)$oID . "'");
	$ot_shipping_value = tep_db_fetch_array($ot_shipping_query);


if ($ot_shipping_value['class'] == 'ot_shipping')//a good place to add in other fields to tax
	{
	if (DISPLAY_PRICE_WITH_TAX == 'true') {
		$RunningTax[$default_tax_name]  += ($ot_shipping_value['value'] * $order->info['shipping_tax'] /  ($order->info['shipping_tax'] + 100));
			} else {
		$RunningTax[$default_tax_name] += (($order->info['shipping_tax'] / 100) * $ot_shipping_value['value']);

				}// end if (DISPLAY_PRICE_WITH_TAX == 'true') {
				}// end if ($ot_shipping_value['class'] == 'ot_shipping')

	// end shipping tax calcs

 

and change it to

 

//just adding in shipping tax, don't mind me
	$ot_shipping_query = tep_db_query("
	SELECT value 
	FROM " . TABLE_ORDERS_TOTAL . " 
	WHERE orders_id = '" . (int)$oID . "'
	AND class = 'ot_shipping'");

	while ($ot_shipping_info = tep_db_fetch_array($ot_shipping_query)) {
	  $ot_shipping_value = $ot_shipping_info['value'];

	if (DISPLAY_PRICE_WITH_TAX == 'true') {
		$RunningTax[$default_tax_name]  += ($ot_shipping_value * $order->info['shipping_tax'] /  ($order->info['shipping_tax'] + 100));
			} else {
 $RunningTax[$default_tax_name] += (($order->info['shipping_tax'] / 100) * $ot_shipping_value);

				}// end if (DISPLAY_PRICE_WITH_TAX == 'true') {
  }// end while

	// end shipping tax calcs

//just taking out discount tax, don't mind me
	$ot_coupon_query = tep_db_query("
	SELECT value 
	FROM " . TABLE_ORDERS_TOTAL . " 
	WHERE orders_id = '" . (int)$oID . "'
	AND class = 'ot_coupon'");

	while ($ot_coupon_info = tep_db_fetch_array($ot_coupon_query)) {
	  $ot_coupon_value = $ot_coupon_info['value'];

	if (DISPLAY_PRICE_WITH_TAX == 'true') {
		$RunningTax[$default_tax_name] -= ($ot_coupon_value * $order->info['shipping_tax'] /  ($order->info['shipping_tax'] + 100));
			} else {
 $RunningTax[$default_tax_name] -= (($order->info['shipping_tax'] / 100) * $ot_coupon_value);

				}// end if (DISPLAY_PRICE_WITH_TAX == 'true') {
   }// end while

	// end discount tax calcs

 

 

DJ,

Your support is so refreshing....on the other hand, this problem getting annoying! :blink:

I'm still having the same issue! I dont believe it's the shipping tax that's throwing it off because I offer free shipping. Here's a copy/paste of the results after making the changes you've made (the tax should be $28.05!!!):

 

CA TAX 8.25%: $35.06

Federal Express Ground ( United States): $0.00

Sub-Total: $425.00

Discount Code:15OFF $-85.00

Total: $375.06

Share this post


Link to post
Share on other sites
DJ,

Your support is so refreshing....on the other hand, this problem getting annoying! :blink:

I'm still having the same issue! I dont believe it's the shipping tax that's throwing it off because I offer free shipping. Here's a copy/paste of the results after making the changes you've made (the tax should be $28.05!!!):

 

CA TAX 8.25%: $35.06

Federal Express Ground ( United States): $0.00

Sub-Total: $425.00

Discount Code:15OFF $-85.00

Total: $375.06

 

 

Actually, that should be a 20% coupon!

Share this post


Link to post
Share on other sites

Hi Folks,

I got some problems:

 

1.)I installed the 2.5 package and upgraded it to 2.6. When I update anything (customers details, add a product or change a price) a new entry in order_total is written:

Before changing details in order editor:

before.gif

After changing details in order editor:

after.gif

 

For each time I update the order a new entry for the tax is written to the database. (See pic above) When I want to print my invoice it looks like that:

rechnung_after.gif

 

How to avoid such entries with tax rates?

 

2.)When I update price the tax, subtotal and total is not correct:

rechnung_after_big.gif

 

These values are the original values before editing the order.

 

Any ideas?

Share this post


Link to post
Share on other sites
DJ,

Your support is so refreshing....on the other hand, this problem getting annoying! :blink:

I'm still having the same issue! I dont believe it's the shipping tax that's throwing it off because I offer free shipping. Here's a copy/paste of the results after making the changes you've made (the tax should be $28.05!!!):

 

CA TAX 8.25%: $35.06

Federal Express Ground ( United States): $0.00

Sub-Total: $425.00

Discount Code:15OFF $-85.00

Total: $375.06

 

And you performed all the changes and changed every instance of "ot_payment" to "ot_coupon"? Are the taxes calculated correctly after adding a product?


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 Folks,

I got some problems:

 

1.)I installed the 2.5 package and upgraded it to 2.6. When I update anything (customers details, add a product or change a price) a new entry in order_total is written:

Before changing details in order editor:

After changing details in order editor:

 

For each time I update the order a new entry for the tax is written to the database. (See pic above) When I want to print my invoice it looks like that:

 

How to avoid such entries with tax rates?

This is strange- this problem was supposed to be fixed as of v2.4.2. Not only should new entries not be created but zero value entries should be deleted. Are you using a modifed file?

 

Does your file include the following line of code:

if (($ot_class == "ot_tax") && (preg_replace("/:$/","",$ot_title) == $key))

You mentioned that you upgraded from v2.5 to v2.6. Did you get the changes from v2.5.1 through v2.5.4?

 

2.)When I update price the tax, subtotal and total is not correct:

 

These values are the original values before editing the order.

 

Any ideas?

This is also very strange.

 

Are the totals calculated properly when adding a product?

 

Do the on-the-fly (JavaScript) calculations work properly when editing an 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.

Share this post


Link to post
Share on other sites

Hi djmonkey1,

I took the 2.54 edit_order.php file and upgraded it like it was written in the 2.6 upgrade.txt

Here is the source:

http://nopaste.php-q.net/226657

 

What about the other files in 2.6 package? I kept the 2.5 files on my server.

 

When I add a produkt, total is properly calculated, but when I remove a produkt, total is wrong.

 

Javascript calculations are right!

Edited by thomas1981

Share this post


Link to post
Share on other sites
Hi djmonkey1,

I took the 2.54 edit_order.php file and upgraded it like it was written in the 2.6 upgrade.txt

Here is the source:

http://nopaste.php-q.net/226657

 

What about the other files in 2.6 package? I kept the 2.5 files on my server.

 

When I add a produkt, total is properly calculated, but when I remove a produkt, total is wrong.

 

Javascript calculations are right!

 

Is the difference between the displayed subtotal and what the subtotal should be always $1.00?


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

Damn, i f**ked up my order.php class and now it works. When I copy the extended order.php class from the package everything works. :) No problems at all and no double entries. Horay! Thanks for your help and time! :)

 

But there is another problem: I use sppc and there must be a way to use both systems:

 

when a customer makes an order with an sppc account, flag = sppc_order

when a customer makes a "normal order" flag = normal_order

when a customer gets discount through edit order flag = eo_order

 

when i use these flags and put them into db, i can easily check via query which kind of optimized order.php should be included to build the invoice and settings into db. so i do not have to mix up the order.php class.

 

what do you think about this theory to use both systems?

Share this post


Link to post
Share on other sites
Damn, i f**ked up my order.php class and now it works. When I copy the extended order.php class from the package everything works. :) No problems at all and no double entries. Horay! Thanks for your help and time! :)

 

But there is another problem: I use sppc and there must be a way to use both systems:

 

when a customer makes an order with an sppc account, flag = sppc_order

when a customer makes a "normal order" flag = normal_order

when a customer gets discount through edit order flag = eo_order

 

when i use these flags and put them into db, i can easily check via query which kind of optimized order.php should be included to build the invoice and settings into db. so i do not have to mix up the order.php class.

 

what do you think about this theory to use both systems?

 

I'm not sure what it is you're trying to do. I use SPPC and I've never had a problem with Order Editor; to my knowledge SPPC doesn't modify the admin side order class file. If you wanted to custom edit the admin side order class so Order Editor would always pull the right prices from the database for each customer depending on their group id, that would be neat but wouldn't require separate files.


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

After the installation of the latest version, I got an error message:

 

Parse error: parse error, unexpected T_STRING in /var/www/html/states/admin/includes/functions/general.php on line 97

 

Can anyone tell what is going on? Many thanks in advance.

 

Here is the code:

 

<?php
/*
 $Id: general.php,v 1.160 2003/07/12 08:32:47 hpdl Exp $

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

 Copyright (c) 2003 osCommerce

 Master Products - JOHNSON - 05/07/2003 matti@suomedia.com

 Copyright (c) 2003 Suomedia - Dynamic Content Management  

 Released under the GNU General Public License
*/

////
//



/// Begin mods for Order Editor
// Return the tax description for a zone / class
// TABLES: tax_rates;
 function tep_get_tax_description($class_id, $country_id, $zone_id) {
$tax_query = tep_db_query("select tax_description from " . TABLE_TAX_RATES . " tr left join " . TABLE_ZONES_TO_GEO_ZONES . " za on (tr.tax_zone_id = za.geo_zone_id) left join " . TABLE_GEO_ZONES . " tz on (tz.geo_zone_id = tr.tax_zone_id) where (za.zone_country_id is null or za.zone_country_id = '0' or za.zone_country_id = '" . (int)$country_id . "') and (za.zone_id is null or za.zone_id = '0' or za.zone_id = '" . (int)$zone_id . "') and tr.tax_class_id = '" . (int)$class_id . "' order by tr.tax_priority");
if (tep_db_num_rows($tax_query)) {
  $tax_description = '';
  while ($tax = tep_db_fetch_array($tax_query)) {
	$tax_description .= $tax['tax_description'] . ' + ';
  }
  $tax_description = substr($tax_description, 0, -3);

  return $tax_description;
} else {
  return ENTRY_TAX;
}
 }

////

// Function	: tep_get_country_id
 // Arguments   : country_name		country name string
 // Return	  : country_id
 // Description : Function to retrieve the country_id based on the country's name
 function tep_get_country_id($country_name) {
$country_id_query = tep_db_query("select * from " . TABLE_COUNTRIES . " where countries_name = '" . $country_name . "'");
if (!tep_db_num_rows($country_id_query)) {
  return 0;
}
else {
  $country_id_row = tep_db_fetch_array($country_id_query);
  return $country_id_row['countries_id'];
}
 }

  // Function	: tep_get_zone_id
 // Arguments   : country_id		country id string	zone_name		state/province name
 // Return	  : zone_id
 // Description : Function to retrieve the zone_id based on the zone's name
 function tep_get_zone_id($country_id, $zone_name) {
$zone_id_query = tep_db_query("select * from " . TABLE_ZONES . " where zone_country_id = '" . $country_id . "' and zone_name = '" . $zone_name . "'");
if (!tep_db_num_rows($zone_id_query)) {
  return 0;
}
else {
  $zone_id_row = tep_db_fetch_array($zone_id_query);
  return $zone_id_row['zone_id'];
}
 }


// Function	: tep_html_quotes
 // Arguments   : string	any string
 // Return	  : string with single quotes converted to html equivalent
 // Description : Function to change quotes to HTML equivalents for form inputs.
 function tep_html_quotes($string) {
return str_replace("'", "'", $string);
 }

/////end Order Editor mods















Redirect to another page or site
 function tep_redirect($url) {
global $logger;

header('Location: ' . $url);

if (STORE_PAGE_PARSE_TIME == 'true') {
  if (!is_object($logger)) $logger = new logger;
  $logger->timer_stop();
}

exit;
 }

////
// Parse the data used in the html tags to ensure the tags will not break
 function tep_parse_input_field_data($data, $parse) {
return strtr(trim($data), $parse);
 }

 function tep_output_string($string, $translate = false, $protected = false) {
if ($protected == true) {
  return htmlspecialchars($string);
} else {
  if ($translate == false) {
	return tep_parse_input_field_data($string, array('"' => '"'));
  } else {
	return tep_parse_input_field_data($string, $translate);
  }
}
 }

 function tep_output_string_protected($string) {
return tep_output_string($string, false, true);
 }

 function tep_sanitize_string($string) {
$string = ereg_replace(' +', ' ', $string);

return preg_replace("/[<>]/", '_', $string);
 }

 function tep_customers_name($customers_id) {
$customers = tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customers_id . "'");
$customers_values = tep_db_fetch_array($customers);

return $customers_values['customers_firstname'] . ' ' . $customers_values['customers_lastname'];
 }

 function tep_get_path($current_category_id = '') {
global $cPath_array;

if ($current_category_id == '') {
  $cPath_new = implode('_', $cPath_array);
} else {
  if (sizeof($cPath_array) == 0) {
	$cPath_new = $current_category_id;
  } else {
	$cPath_new = '';
	$last_category_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$cPath_array[(sizeof($cPath_array)-1)] . "'");
	$last_category = tep_db_fetch_array($last_category_query);

	$current_category_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'");
	$current_category = tep_db_fetch_array($current_category_query);

	if ($last_category['parent_id'] == $current_category['parent_id']) {
	  for ($i = 0, $n = sizeof($cPath_array) - 1; $i < $n; $i++) {
		$cPath_new .= '_' . $cPath_array[$i];
	  }
	} else {
	  for ($i = 0, $n = sizeof($cPath_array); $i < $n; $i++) {
		$cPath_new .= '_' . $cPath_array[$i];
	  }
	}

	$cPath_new .= '_' . $current_category_id;

	if (substr($cPath_new, 0, 1) == '_') {
	  $cPath_new = substr($cPath_new, 1);
	}
  }
}

return 'cPath=' . $cPath_new;
 }

 function tep_get_all_get_params($exclude_array = '') {
global $HTTP_GET_VARS;

if ($exclude_array == '') $exclude_array = array();

$get_url = '';

reset($HTTP_GET_VARS);
while (list($key, $value) = each($HTTP_GET_VARS)) {
  if (($key != tep_session_name()) && ($key != 'error') && (!in_array($key, $exclude_array))) $get_url .= $key . '=' . $value . '&';
}

return $get_url;
 }

 function tep_date_long($raw_date) {
if ( ($raw_date == '0000-00-00 00:00:00') || ($raw_date == '') ) return false;

$year = (int)substr($raw_date, 0, 4);
$month = (int)substr($raw_date, 5, 2);
$day = (int)substr($raw_date, 8, 2);
$hour = (int)substr($raw_date, 11, 2);
$minute = (int)substr($raw_date, 14, 2);
$second = (int)substr($raw_date, 17, 2);

return strftime(DATE_FORMAT_LONG, mktime($hour, $minute, $second, $month, $day, $year));
 }

////
// Output a raw date string in the selected locale date format
// $raw_date needs to be in this format: YYYY-MM-DD HH:MM:SS
// NOTE: Includes a workaround for dates before 01/01/1970 that fail on windows servers
 function tep_date_short($raw_date) {
if ( ($raw_date == '0000-00-00 00:00:00') || ($raw_date == '') ) return false;

$year = substr($raw_date, 0, 4);
$month = (int)substr($raw_date, 5, 2);
$day = (int)substr($raw_date, 8, 2);
$hour = (int)substr($raw_date, 11, 2);
$minute = (int)substr($raw_date, 14, 2);
$second = (int)substr($raw_date, 17, 2);

if (@date('Y', mktime($hour, $minute, $second, $month, $day, $year)) == $year) {
  return date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, $year));
} else {
  return ereg_replace('2037' . '$', $year, date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, 2037)));
}

 }

 function tep_datetime_short($raw_datetime) {
if ( ($raw_datetime == '0000-00-00 00:00:00') || ($raw_datetime == '') ) return false;

$year = (int)substr($raw_datetime, 0, 4);
$month = (int)substr($raw_datetime, 5, 2);
$day = (int)substr($raw_datetime, 8, 2);
$hour = (int)substr($raw_datetime, 11, 2);
$minute = (int)substr($raw_datetime, 14, 2);
$second = (int)substr($raw_datetime, 17, 2);

return strftime(DATE_TIME_FORMAT, mktime($hour, $minute, $second, $month, $day, $year));
 }

 function tep_get_category_tree($parent_id = '0', $spacing = '', $exclude = '', $category_tree_array = '', $include_itself = false) {
global $languages_id;

if (!is_array($category_tree_array)) $category_tree_array = array();
if ( (sizeof($category_tree_array) < 1) && ($exclude != '0') ) $category_tree_array[] = array('id' => '0', 'text' => TEXT_TOP);

if ($include_itself) {
  $category_query = tep_db_query("select cd.categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " cd where cd.language_id = '" . (int)$languages_id . "' and cd.categories_id = '" . (int)$parent_id . "'");
  $category = tep_db_fetch_array($category_query);
  $category_tree_array[] = array('id' => $parent_id, 'text' => $category['categories_name']);
}

$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and c.parent_id = '" . (int)$parent_id . "' order by c.sort_order, cd.categories_name");
while ($categories = tep_db_fetch_array($categories_query)) {
  if ($exclude != $categories['categories_id']) $category_tree_array[] = array('id' => $categories['categories_id'], 'text' => $spacing . $categories['categories_name']);
  $category_tree_array = tep_get_category_tree($categories['categories_id'], $spacing . '???', $exclude, $category_tree_array);
}

return $category_tree_array;
 }

 function tep_draw_products_pull_down($name, $parameters = '', $exclude = '') {
global $currencies, $languages_id;

if ($exclude == '') {
  $exclude = array();
}

$select_string = '<select name="' . $name . '"';

if ($parameters) {
  $select_string .= ' ' . $parameters;
}

$select_string .= '>';

$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by products_name");
while ($products = tep_db_fetch_array($products_query)) {
  if (!in_array($products['products_id'], $exclude)) {
	$select_string .= '<option value="' . $products['products_id'] . '">' . $products['products_name'] . ' (' . $currencies->format($products['products_price']) . ')</option>';
  }
}

$select_string .= '</select>';

return $select_string;
 }

 function tep_options_name($options_id) {
global $languages_id;

$options = tep_db_query("select products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$options_id . "' and language_id = '" . (int)$languages_id . "'");
$options_values = tep_db_fetch_array($options);

return $options_values['products_options_name'];
 }

 function tep_values_name($values_id) {
global $languages_id;

$values = tep_db_query("select products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int)$values_id . "' and language_id = '" . (int)$languages_id . "'");
$values_values = tep_db_fetch_array($values);

return $values_values['products_options_values_name'];
 }

 function tep_info_image($image, $alt, $width = '', $height = '') {
if (tep_not_null($image) && (file_exists(DIR_FS_CATALOG_IMAGES . $image)) ) {
  $image = tep_image(DIR_WS_CATALOG_IMAGES . $image, $alt, $width, $height);
} else {
  $image = TEXT_IMAGE_NONEXISTENT;
}

return $image;
 }

 function tep_break_string($string, $len, $break_char = '-') {
$l = 0;
$output = '';
for ($i=0, $n=strlen($string); $i<$n; $i++) {
  $char = substr($string, $i, 1);
  if ($char != ' ') {
	$l++;
  } else {
	$l = 0;
  }
  if ($l > $len) {
	$l = 1;
	$output .= $break_char;
  }
  $output .= $char;
}

return $output;
 }

 function tep_get_country_name($country_id) {
$country_query = tep_db_query("select countries_name from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$country_id . "'");

if (!tep_db_num_rows($country_query)) {
  return $country_id;
} else {
  $country = tep_db_fetch_array($country_query);
  return $country['countries_name'];
}
 }

 function tep_get_zone_name($country_id, $zone_id, $default_zone) {
$zone_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country_id . "' and zone_id = '" . (int)$zone_id . "'");
if (tep_db_num_rows($zone_query)) {
  $zone = tep_db_fetch_array($zone_query);
  return $zone['zone_name'];
} else {
  return $default_zone;
}
 }

 function tep_not_null($value) {
if (is_array($value)) {
  if (sizeof($value) > 0) {
	return true;
  } else {
	return false;
  }
} else {
  if ( (is_string($value) || is_int($value)) && ($value != '') && ($value != 'NULL') && (strlen(trim($value)) > 0)) {
	return true;
  } else {
	return false;
  }
}
 }

 function tep_browser_detect($component) {
global $HTTP_USER_AGENT;

return stristr($HTTP_USER_AGENT, $component);
 }

 function tep_tax_classes_pull_down($parameters, $selected = '') {
$select_string = '<select ' . $parameters . '>';
$classes_query = tep_db_query("select tax_class_id, tax_class_title from " . TABLE_TAX_CLASS . " order by tax_class_title");
while ($classes = tep_db_fetch_array($classes_query)) {
  $select_string .= '<option value="' . $classes['tax_class_id'] . '"';
  if ($selected == $classes['tax_class_id']) $select_string .= ' SELECTED';
  $select_string .= '>' . $classes['tax_class_title'] . '</option>';
}
$select_string .= '</select>';

return $select_string;
 }

 function tep_geo_zones_pull_down($parameters, $selected = '') {
$select_string = '<select ' . $parameters . '>';
$zones_query = tep_db_query("select geo_zone_id, geo_zone_name from " . TABLE_GEO_ZONES . " order by geo_zone_name");
while ($zones = tep_db_fetch_array($zones_query)) {
  $select_string .= '<option value="' . $zones['geo_zone_id'] . '"';
  if ($selected == $zones['geo_zone_id']) $select_string .= ' SELECTED';
  $select_string .= '>' . $zones['geo_zone_name'] . '</option>';
}
$select_string .= '</select>';

return $select_string;
 }

 function tep_get_geo_zone_name($geo_zone_id) {
$zones_query = tep_db_query("select geo_zone_name from " . TABLE_GEO_ZONES . " where geo_zone_id = '" . (int)$geo_zone_id . "'");

if (!tep_db_num_rows($zones_query)) {
  $geo_zone_name = $geo_zone_id;
} else {
  $zones = tep_db_fetch_array($zones_query);
  $geo_zone_name = $zones['geo_zone_name'];
}

return $geo_zone_name;
 }

 function tep_address_format($address_format_id, $address, $html, $boln, $eoln) {
$address_format_query = tep_db_query("select address_format as format from " . TABLE_ADDRESS_FORMAT . " where address_format_id = '" . (int)$address_format_id . "'");
$address_format = tep_db_fetch_array($address_format_query);

$company = tep_output_string_protected($address['company']);
if (isset($address['firstname']) && tep_not_null($address['firstname'])) {
  $firstname = tep_output_string_protected($address['firstname']);
  $lastname = tep_output_string_protected($address['lastname']);
} elseif (isset($address['name']) && tep_not_null($address['name'])) {
  $firstname = tep_output_string_protected($address['name']);
  $lastname = '';
} else {
  $firstname = '';
  $lastname = '';
}
$street = tep_output_string_protected($address['street_address']);
$suburb = tep_output_string_protected($address['suburb']);
$city = tep_output_string_protected($address['city']);
$state = tep_output_string_protected($address['state']);
if (isset($address['country_id']) && tep_not_null($address['country_id'])) {
  $country = tep_get_country_name($address['country_id']);

  if (isset($address['zone_id']) && tep_not_null($address['zone_id'])) {
	$state = tep_get_zone_code($address['country_id'], $address['zone_id'], $state);
  }
} elseif (isset($address['country']) && tep_not_null($address['country'])) {
  $country = tep_output_string_protected($address['country']);
} else {
  $country = '';
}
$postcode = tep_output_string_protected($address['postcode']);
$zip = $postcode;

if ($html) {
// HTML Mode
  $HR = '<hr>';
  $hr = '<hr>';
  if ( ($boln == '') && ($eoln == "\n") ) { // Values not specified, use rational defaults
	$CR = '<br>';
	$cr = '<br>';
	$eoln = $cr;
  } else { // Use values supplied
	$CR = $eoln . $boln;
	$cr = $CR;
  }
} else {
// Text Mode
  $CR = $eoln;
  $cr = $CR;
  $HR = '----------------------------------------';
  $hr = '----------------------------------------';
}

$statecomma = '';
$streets = $street;
if ($suburb != '') $streets = $street . $cr . $suburb;
if ($country == '') $country = tep_output_string_protected($address['country']);
if ($state != '') $statecomma = $state . ', ';

$fmt = $address_format['format'];
eval("\$address = \"$fmt\";");

if ( (ACCOUNT_COMPANY == 'true') && (tep_not_null($company)) ) {
  $address = $company . $cr . $address;
}

return $address;
 }

 ////////////////////////////////////////////////////////////////////////////////////////////////
 //
 // Function	: tep_get_zone_code
 //
 // Arguments   : country		   country code string
 //			   zone			  state/province zone_id
 //			   def_state		 default string if zone==0
 //
 // Return	  : state_prov_code   state/province code
 //
 // Description : Function to retrieve the state/province code (as in FL for Florida etc)
 //
 ////////////////////////////////////////////////////////////////////////////////////////////////
 function tep_get_zone_code($country, $zone, $def_state) {

$state_prov_query = tep_db_query("select zone_code from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' and zone_id = '" . (int)$zone . "'");

if (!tep_db_num_rows($state_prov_query)) {
  $state_prov_code = $def_state;
}
else {
  $state_prov_values = tep_db_fetch_array($state_prov_query);
  $state_prov_code = $state_prov_values['zone_code'];
}

return $state_prov_code;
 }

 function tep_get_uprid($prid, $params) {
$uprid = $prid;
if ( (is_array($params)) && (!strstr($prid, '{')) ) {
  while (list($option, $value) = each($params)) {
	$uprid = $uprid . '{' . $option . '}' . $value;
  }
}

return $uprid;
 }

 function tep_get_prid($uprid) {
$pieces = explode('{', $uprid);

return $pieces[0];
 }

 function tep_get_languages() {
$languages_query = tep_db_query("select languages_id, name, code, image, directory from " . TABLE_LANGUAGES . " order by sort_order");
while ($languages = tep_db_fetch_array($languages_query)) {
  $languages_array[] = array('id' => $languages['languages_id'],
							 'name' => $languages['name'],
							 'code' => $languages['code'],
							 'image' => $languages['image'],
							 'directory' => $languages['directory']);
}

return $languages_array;
 }

.................

Share this post


Link to post
Share on other sites
After the installation of the latest version, I got an error message:

 

Parse error: parse error, unexpected T_STRING in /var/www/html/states/admin/includes/functions/general.php on line 97

 

Can anyone tell what is going on? Many thanks in advance.

 

Here is the code:

The error specifically references line 97; you need to go to that line and change

Redirect to another page or site

to

// Redirect to another page or site

In the future please do not post entire pages of code unless absolutely necessary. In this case the error you were seeing told you exactly what line to look at.


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

SOLUTION for QTPro atrributes support in Order Editor.

 

I work with ordereditor v.2.5 and QTpro v.4.25

 

IMPORTANT NOTE: I do not have my shop set to default STOCK check ( i use an option that detracts stock when my orders hit the "delivered" status, so orders.php deals with stock check.)

but i think that will not be a problem, since order editor already checks stock.

 

The whole idea is to fill table collumn "products_stock_attributes" from TABLE_ORDERS_PRODUCTS with the correct value and stock should be correct.

 

Maybe someone else can check the regular Stock check and fill this in.

 

Ok. in edit_orders.php find this, about line 438:

		// 2.1.1 Get Product Attribute Info
		if(is_array ($_POST['add_product_options']))
		{
			foreach($_POST['add_product_options'] as $option_id => $option_value_id)
			{
				$result = tep_db_query("SELECT * FROM " . TABLE_PRODUCTS_ATTRIBUTES . " 
				pa LEFT JOIN " . TABLE_PRODUCTS_OPTIONS . " po 
				ON po.products_options_id=pa.options_id 
				LEFT JOIN " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov 
				ON pov.products_options_values_id=pa.options_values_id 
				WHERE products_id=" . $_POST['add_product_products_id'] . " 
				and options_id=" . $option_id . " 
				and options_values_id=" . $option_value_id . " 
				and po.language_id = '" . (int)$languages_id . "' 
				and pov.language_id = '" . (int)$languages_id . "'");

				$row = tep_db_fetch_array($result);
				extract($row, EXTR_PREFIX_ALL, "opt");
				$AddedOptionsPrice += $opt_options_values_price;
				$option_value_details[$option_id][$option_value_id] = array ("options_values_price" => $opt_options_values_price);
				$option_names[$option_id] = $opt_products_options_name;
				$option_values_names[$option_value_id] = $opt_products_options_values_name;
			}
		}

 

change to:

 

	// 2.1.1 Get Product Attribute Info
		if(is_array ($_POST['add_product_options']))
		{
			foreach($_POST['add_product_options'] as $option_id => $option_value_id)
			{
				$result = tep_db_query("SELECT * FROM " . TABLE_PRODUCTS_ATTRIBUTES . " 
				pa LEFT JOIN " . TABLE_PRODUCTS_OPTIONS . " po 
				ON po.products_options_id=pa.options_id 
				LEFT JOIN " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov 
				ON pov.products_options_values_id=pa.options_values_id 
				WHERE products_id=" . $_POST['add_product_products_id'] . " 
				and options_id=" . $option_id . " 
				and options_values_id=" . $option_value_id . " 
				and po.language_id = '" . (int)$languages_id . "' 
				and pov.language_id = '" . (int)$languages_id . "'");

				$row = tep_db_fetch_array($result);
				extract($row, EXTR_PREFIX_ALL, "opt");
				$AddedOptionsPrice += $opt_options_values_price;
				$option_value_details[$option_id][$option_value_id] = array ("options_values_price" => $opt_options_values_price);
				$option_names[$option_id] = $opt_products_options_name;
				$option_values_names[$option_value_id] = $opt_products_options_values_name;
   	  $products_stock_attributes_array = array();
	  $products_stock_attributes_array[] = $option_id . "-" . $option_value_id;
	  $products_stock_attributes = implode(",", $products_stock_attributes_array);

			}
		}

row 508

			// 2.2 UPDATE ORDER ####
		$Query = "INSERT INTO " . TABLE_ORDERS_PRODUCTS . " SET
		  orders_id = '" . $oID . "',
		  products_id = '" . $_POST['add_product_products_id'] . "',
		  products_model = '" . $p_products_model . "',
		  products_name = '" . tep_html_quotes($p_products_name) . "',
		  products_price = '". $p_products_price . "',
		  final_price = '" . ($p_products_price + $AddedOptionsPrice) . "',
	   products_tax = '" . tep_get_tax_rate($p_products_tax_class_id, $countryid, $zoneid) . "',
		  products_quantity = '" . $_POST['add_product_quantity'] . "'";
		  tep_db_query($Query);
		  $new_product_id = tep_db_insert_id();

 

change to:

 

		// 2.2 UPDATE ORDER ####
		$Query = "INSERT INTO " . TABLE_ORDERS_PRODUCTS . " SET
		  orders_id = '" . $oID . "',
		  products_id = '" . $_POST['add_product_products_id'] . "',
		  products_model = '" . $p_products_model . "',
		  products_name = '" . tep_html_quotes($p_products_name) . "',
		  products_price = '". $p_products_price . "',
		  final_price = '" . ($p_products_price + $AddedOptionsPrice) . "',
		  products_tax = '" . tep_get_tax_rate($p_products_tax_class_id, $countryid, $zoneid) . "',
		  products_quantity = '" . $_POST['add_product_quantity'] . "',
		  products_stock_attributes = '" . $products_stock_attributes . "'";
		  tep_db_query($Query);
		  $new_product_id = tep_db_insert_id();

 

At least this works for me. Hope it helps you.

 

Grtz Lenny

Share this post


Link to post
Share on other sites

Trying to install Order editor to better serve my customers. I think I may have installed it correctly, but due to some code modifcation for my "packing slip w/ product images" contrib, I had some confusion upon installation, and wouldn't you know it, i got an error. SOOOOOOOOOOO does anyone have better documentation on how to install this contrib, and had anyone installed this contrib while having the Packing slip w/ product images contrib? Yes, I do need both. Below is the error I got after the install, I have no idea how to correct it and I went to error located in the file... and saw nothing that said ,"hey this is the error". Maybe it was installed but needed to be configured, the documentation mentioned something about this but did not give a how-to. any help... is greatly appreciated. ok listed below is the error. Any ideas?

 

 

Had an error on line 45 of admin/includes/filenames.php

was referring to

"define('FILENAME_TAX_RATES', 'tax_rates.php');"


We must be the change we wish to see in the world.

------------------------------------------------------------

p.s. BACKUP!

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

×