Jump to content
Tsimi

Order Editor for 2.3.3.4?

Recommended Posts

i would like to know if anyone has one of the following two add-ons below up and "running" on a osC 2.3.3.4 shop.

if yes, which version works "without" getting any error messages? most of these version require additional add-ons to be installed which i don't need. or how do YOU edit your orders? any other tool available?

 

order editor for osC 2.3

 

http://addons.oscommerce.com/info/7844

 

order editor

 

http://addons.oscommerce.com/info/1435

 

at this point i would like to say a few words regarding the two add-ons.

 

the first link; suppose to run on a 2.3 osC shop. IT DOESN'T!!!

the first download works if you have mindsparx admin which i don't need. the second link suppose to fix that but it doesn't.

and the indian dude, well,.....no comment!

 

the second link; the add-on area is ridiculous i have never seen so many crappy uploads for an add-on. (excuse my language) that area needs definetely cleaning. why in gods name are people not uploading "full packages"? and before you upload something make sure you take out your crappy custom codes from other add-ons! and don't code things so that people are forced to install other additional add-ons to make this one run, that is total bullshit (again excuse my language)

 

after hours of trying and trying i'm frustrated and quite pissed off. i'll have a beer and cool down.....

Share this post


Link to post
Share on other sites

Hi lambros,

 

If it was me I would start with

 

surfalot 18 Nov 2009

 

As most of his stuff was good then it is most likely just a question of getting rid of v2.2 code and changing to 2.3 (including template_top template bottom etc) and getting rid of the old html mainly cosmetic. Generally the files needing changed are top level /admin

 

You just need to watch the buttons as some will be probably input buttons and others just the links

Done a mail manager contribution think he had 25 buttons done my head in (w00t) getting right.

If you are unlucky there may be some MYsqli problems but again generally just a few lines of code to fix.

 

Regards

John

 

PS: hope the beer was COLD :thumbsup:

 


To improve is to change; to be perfect is to change often.

 

Share this post


Link to post
Share on other sites

@@Tsimi

 

I have both of these running on 2.3.3.4 - see my thread for the changes required.

 

Look at post no 30 then post 58, may be one or 2 more on changes needed - but works with no error logs for me on 2.3.3.4 and php 5.4.21

 

Thanks

Edited by Mort-lemur

Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Share this post


Link to post
Share on other sites

with add-on: http://addons.oscommerce.com/info/7844 (saiSoftIndia 8 Aug 2011, ver1.3 i think)

 

remove unknown code inside edit_orders.php line 1923 -1927

<!-- Comment Toolbar 4.0 bof //-->
 <tr>
 <td><?php //include ("comment_bar.php"); ?></td>
 </tr>
<!-- Comment Toolbar 4.0 eof //-->

with AJAX set to "true" no problem so far.

 

with AJAX set to "false"

 

1146 - Table 'walkiedoggie_db.eorder_text' doesn't exist

 

SELECT * FROM eorder_text where eorder_text_id = '1' and language_id = '1'

 

forces you to install Send HTML email V2 add-on = not good!

 

so i uncomment line 740 to 744 inside the edit_orders.php

if (EMAIL_USE_HTML == 'true'){
			 $text_query = tep_db_query("SELECT * FROM eorder_text where eorder_text_id = '2' and language_id = '" . $languages_id . "'");	
		} else{
			 $text_query = tep_db_query("SELECT * FROM eorder_text where eorder_text_id = '1' and language_id = '" . $languages_id . "'");
		}

and then i get this

 

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in C:\xxx\xxx\xxx\xxx\xxx\xxx\xxx\includes\functions\database.php on line 103

 

Fatal error: Call to undefined function tep_add_base_ref() in xxx\xxx\xxx\xxx\xxx\xxx\xxx\xxx\edit_orders.php on line 851

 

so again from one error to the next and it goes on like this.

 

i think kymation said once that "tep_add_base_ref()" is not a standart osC code. probably another forgotten crappy add-on code?

Edited by Tsimi

Share this post


Link to post
Share on other sites

@@Tsimi The first bit refers to Admin comments bar - which is another mod - just comment it out.

 

I have never tried it with ajax off - I keep it on

 

as for the final error - I dont know as I dont use pictures mode


Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Share this post


Link to post
Share on other sites

@@Mort-lemur

 

thank you for your help and advise. i installed it with ajax set to true for now but if i find time i'll probably do what joli1811 recommended, just take the surfalot version and try to clean it.

 

 

 

that is what i meant when i said people leave their crappy code inside the add-on.

this add-on got updated so many times by so many people that have no clue on how to prepair and upload a "clean, running" add-on.

 

if the add-on works with AJAX then the admin option "use ajax true or false" should be taken out and the add-on should be named "AJAX order editor"

but even then all the uncomplete codes are still there inside, causing no error but still there.

when i played around with superfish megamenu i couldn't get it running as it should so i didn't release it as add-on because it shouldn't be released if it doesn't run

100% on a clean install of osC 2.3.3.4

 

burt should add this add-on to his "add-ons that break on osC 2.3.3.4" topic.

Share this post


Link to post
Share on other sites

i followed Johns advise and took the surfalot (18 Nov 2009) version and winmerged everything.

i took out the HTML eMail thing and made sure that there is no other uncomplete add-on code inside.

and now finally it seems to work 100% on osC 2.3.3.4

 

now with AJAX set to "false" or "true" i can edit and update successfully.

i can't test the e-mails on my local XAMP but i get send success messages with and without AJAX.

 

i attached the edit_orders.php file so feel free to try it out. i would like to have some feedback regarding the e-mail function since that is the only thing i couldn't really test.

 

i'll drink a "cold" beer now. :beer: 乾杯!

Edited by Tsimi

Share this post


Link to post
Share on other sites

@@Tsimi I cant trial your version as I use some of the stuff that you stripped out. But Im sure someone will give it a go and report back.

 

Many Thanks


Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Share this post


Link to post
Share on other sites

that's ok heather. thank YOU for adapting this add-on to 2.3.3.x in the first place, you're doing a great job with osC 2.3.3.4 add-ons.

 

at this point maybe i should mention that "my" version of edit orders doesn't support following add-ons

 

shipping label pdf http://addons.oscommerce.com/info/2803

google maps + direction http://addons.oscommerce.com/info/6888

pdf invoice admin 1.6.2 http://addons.oscommerce.com/info/3027

Send Html Email installed ( http://addons.oscommerce.com/info/1091 )

 

these are all stripped out. Now it's a surfalot 5.0.7 version for osC 2.3.3.x.

If you want order editor to be compatible with the add-ons i listed above then take Mort-lemurs Version.

 

EDIT: totally forgot! the edit_order_ajax.php file also needs to be updated/replaced.

Edited by Tsimi

Share this post


Link to post
Share on other sites

i just remembered, that i was the one complaining about others not uploading full packages. :shifty:

 

i attached the full package. as mentioned above, it's a surfalot 5.0.7 version for osC 2.3.3.x.

 

*the e-mail function needs testing.

Share this post


Link to post
Share on other sites

I have run it to a problem. I have been using order editor and running under 2.3.3.4. I whitched sales tax program over to oscommerce_taxrates be cause it is a lot cleaner to update and run. Runs great in checkout but not at all in order editor. When you go and add an item it gets a headack, greating the followin error code:

 

Warning: require_once(includes/modules/taxrates/func.taxrates.php) [function.require-once]: failed to open stream: No such file or directory in /home/content/l/a/d/lady3597/html/includes/modules/order_total/ot_taxrates.php on line 37

 

Fatal error: require_once() [function.require]: Failed opening required 'includes/modules/taxrates/func.taxrates.php' (include_path='.:/usr/local/php5/lib/php') in /home/content/l/a/d/lady3597/html/includes/modules/order_total/ot_taxrates.php on line 37

 

This error is coming from the new add on (oscommerce_taxrates).

 

Any solutions to get it to work with order editor.

Thanks

Share this post


Link to post
Share on other sites

I've been trying to use the editor on my eshop (2.3.1) but I just can't make it work...

 

I'm using the saiSoftIndia 8 Aug 2011 for http://addons.oscommerce.com/info/7844 but nothing works. I've also tried the kornel76 16 Apr 2014 change and also the versio by Tsimi but no luck... Nothing updated. Tried also without ajax and again nothing... I fill in the new details and then what :/

Share this post


Link to post
Share on other sites

There are "usually" two ways how the order editor updates the information that you enter. One way is by using Ajax means the moment you input new data it updates automatically. The other way is to deactivate Ajax (somewhere in the configuration area) and then you have to push a update button every time you edit the information. Maybe something went wrong during your Installation.

As you probably read i was a couple of times at the edge because of this stupid but nevertheless important add-on.

Just double check the changes again. And report back

Edited by Tsimi

Share this post


Link to post
Share on other sites

@@Mort-lemur

 

Question 1:

I was wondering when you add a new order_total field (ot_custom) does it calculate the taxes correctly?

 

Question 2:

And can you add a new ot_custom field in AJAX mode? I couldn't. Because when I enter the title I have to click "tab-key" or click with my mouse cursor on the amount field but just at that moment the page updates (AJAX) and it disappears.

 

If your answer for question 1 is "no" then look at this following fix. (from bugfunder, 23. Jan. 2011, http://addons.oscommerce.com/info/1435)

This fix has to be applied to both files edit_orders.php and edit_orders_ajax.php

 

Look for this
 

$j=1; //giving something a sort order of 0 ain't my bag baby
$new_order_totals = array();

add right after it
 

//BOF ot_custom tax fix
  $tax_to_add=0;
//EOF ot_custom tax fix

Look for this
 

if ( ( ($order_totals[$i]['code'] == 'ot_tax') && ($order_totals[$i]['code'] == $ot_class) && ($order_totals[$i]['title'] == $ot_title) ) || ( ($order_totals[$i]['code'] != 'ot_tax') && ($order_totals[$i]['code'] == $ot_class) ) ) { //6
//only good for components that show up in the $order_totals array

add right after it
 

//BOF ot_custom tax fix            
  if ($order_totals[$i]['code'] == 'ot_tax') {
      $order_totals[$i]['value']+=$tax_to_add;
      $order_totals[$i]['text']=$currencies->format($order_totals[$i]['value'], true, $order->info['currency'], $order->info['currency_value']);
  }
//EOF ot_custom tax fix

Look for this
 

} elseif ( (tep_not_null($ot_value)) && (tep_not_null($ot_title)) ) { // this modifies if (!strstr($ot_class, 'ot_custom')) { //3

add right after it
 

//BOF ot_custom tax fix
 //This calculates tax on ot_custom
   $tax_to_add += $ot_value * $tax / (100 + $tax);
//EOF ot_custom tax fix

Look for this
 

     $j++;
  } //end 7
} //end 2

and add right "above" it
 

//BOF ot_custom tax fix            
 //This calculates tax on non-standard
   $tax_to_add += $ot_value * $tax / (100 + $tax);
   $order->info['total'] += $ot_value;
//EOF ot_custom tax fix    

This worked for me so far. I have only one tax class in my shop therefore i can't tell if that fix would work on a shop with multiple tax classes.

And since you use a different version then i do it could be that this fix is already applied in your files and therefore not necessary anymore.

 

Share this post


Link to post
Share on other sites

@@Tsimi Sent you a pm


Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Share this post


Link to post
Share on other sites

Question 2:

And can you add a new ot_custom field in AJAX mode? I couldn't. Because when I enter the title I have to click "tab-key" or click with my mouse cursor on the amount field but just at that moment the page updates (AJAX) and it disappears.

 

I have exactly the same problem and I don't know how to fix it. I think the bug came out after updating my site from 2.3.1 to 2.3.3.3

 

If javascript updating is turned off then I am able to add cusom order totals but then again I can't change shipping methods.

 

Any idea how to fix it?

Share this post


Link to post
Share on other sites

oh I just found th fix. I wonder how the code worked before but started acting weird after the update. anyway, If you are also uable to add custom order totals whith ajax turned on do this:

 

in edit_orders.php find:

 

 

      if (ORDER_EDITOR_USE_AJAX == 'true') {
      echo '                    <td align="right" class="dataTableContent"><input name="update_totals['.$i.'][title]" id="'.$id.'[title]" value="' . trim($order->totals[$i]['title']) . '" onChange="obtainTotals()"></td>' . "\n" .
 

 remove onChange="obtainTotals()" so it looks like this:

 

 

      if (ORDER_EDITOR_USE_AJAX == 'true') {
      echo '                    <td align="right" class="dataTableContent"><input name="update_totals['.$i.'][title]" id="'.$id.'[title]" value="' . trim($order->totals[$i]['title']) . '" ></td>' . "\n" .
 

 

Now if you write something in the order total title field, the ajax will not reload. It will reload only if you insert something into value field. So remember to enter the order total title before the amount.

Edited by tarmogr

Share this post


Link to post
Share on other sites

Hello,

 

I am new to Oscommerce and asking if someone can please help me I have install the below contribution

 

install order_editor_for2.3_v1.0  http://addons.oscommerce.com/info/7844

everything is working except the below error whenever I try to add a new product

 

I already have http://addons.oscommerce.com/info/9416

 

but I know it has something to do with the Separate pricing that's the reason why I am getting the error

 

1054 - Unknown column 'customers_group_id' in 'field list'

SELECT customers_group_id FROM customers WHERE customers_id="4"

 

Here is the file edit_orders_add_product.php because since this is new I have to add this somewhere

 

<?php
/*
  $Id: edit_orders_add_product.php v5.0.5 08/27/2007 djmonkey1 Exp $
 
  osCommerce, Open Source E-Commerce Solutions
 
  Copyright © 2007 osCommerce
 
  Released under the GNU General Public License
 
  For Order Editor support or to post bug reports, feature requests, etc, please visit the Order Editor support thread:
  
*/
 
  require('includes/application_top.php');
 
  // include the appropriate functions & classes
  include('order_editor/functions.php');
  include('order_editor/cart.php');
  include('order_editor/order.php');
  include(DIR_WS_LANGUAGES . $language. '/' . 'edit_orders.php');
 
  // Include currencies class
  require(DIR_WS_CLASSES . 'currencies.php');
  $currencies = new currencies();
 
  $oID = tep_db_prepare_input((int)$_GET['oID']);
  $order = new manualOrder($oID);
 
  // Setup variables
  $step = ((isset($_POST['step'])) ? (int)$_POST['step'] : 1);
  $add_product_categories_id = ((isset($_POST['add_product_categories_id'])) ? (int)$_POST['add_product_categories_id'] : '');
  $add_product_products_id = ((isset($_POST['add_product_products_id'])) ? (int)$_POST['add_product_products_id'] : 0);
 
  // $_GET['action'] switch
  if (isset($_GET['action'])) {
    switch ($_GET['action']) {
    
    ////
    // Add a product to the virtual cart
      case 'add_product':
        if ($step != 5) break;
        
        $AddedOptionsPrice = 0;
        
        // Get Product Attribute Info
        if (isset($_POST['add_product_options'])) {
          foreach($_POST['add_product_options'] as $option_id => $option_value_id) {
            $result = tep_db_query("SELECT * FROM products_attributes pa INNER JOIN products_options po ON (po.products_options_id = pa.options_id and po.language_id = '" . $languages_id . "') INNER JOIN products_options_values pov on (pov.products_options_values_id = pa.options_values_id and pov.language_id = '" . $languages_id . "') WHERE products_id = '" . $add_product_products_id . "' and options_id = '" . $option_id . "' and options_values_id = '" . $option_value_id . "'");
            $row = tep_db_fetch_array($result);
if (is_array($row)) extract($row, EXTR_PREFIX_ALL, "opt");
if ($opt_price_prefix == '-')
{$AddedOptionsPrice -= $opt_options_values_price;}
else //default to positive
{$AddedOptionsPrice += $opt_options_values_price;}
            $option_value_details[$option_id][$option_value_id] = array (
"options_values_price" => $opt_options_values_price,
"price_prefix" => $opt_price_prefix);
            $option_names[$option_id] = $opt_products_options_name;
            $option_values_names[$option_value_id] = $opt_products_options_values_name;
 
//add on for downloads
if (DOWNLOAD_ENABLED == 'true') {
        $download_query_raw ="SELECT products_attributes_filename, products_attributes_maxdays, products_attributes_maxcount 
        FROM products_attributes_download
        WHERE products_attributes_id='" . $opt_products_attributes_id . "'";
        
$download_query = tep_db_query($download_query_raw);
        if (tep_db_num_rows($download_query) > 0) {
          $download = tep_db_fetch_array($download_query);
          $filename[$option_id] = $download['products_attributes_filename'];
          $maxdays[$option_id]  = $download['products_attributes_maxdays'];
          $maxcount[$option_id] = $download['products_attributes_maxcount'];
        } //end if (tep_db_num_rows($download_query) > 0) {
} //end if (DOWNLOAD_ENABLED == 'true') {
//end downloads 
 
          } //end foreach($_POST['add_product_options'] as $option_id => $option_value_id) {
        } //end if (isset($_POST['add_product_options'])) {
 
        
        // Get Product Info
        //BOF Added languageid (otherwise products_name is empty)
        //$product_query = tep_db_query("select p.products_model, p.products_price, pd.products_name, p.products_tax_class_id from products p left join products_description pd on pd.products_id = p.products_id where p.products_id = '" . (int)$add_product_products_id . "'");
        $product_query = tep_db_query("select p.products_model, p.products_price, pd.products_name, p.products_tax_class_id from products p left join products_description pd on pd.products_id = p.products_id where p.products_id = '" . (int)$add_product_products_id . "' and pd.language_id = '" . $languages_id . "'");
        //EOF Added languageid
        $product = tep_db_fetch_array($product_query);
        $country_id = oe_get_country_id($order->delivery["country"]);
        $zone_id = oe_get_zone_id($country_id, $order->delivery['state']);
        $products_tax = tep_get_tax_rate($product['products_tax_class_id'], $country_id, $zone_id);
 
 
// 2.1.3  Pull specials price from db if there is an active offer
$special_price = tep_db_query("
SELECT specials_new_products_price 
FROM specials 
WHERE products_id =". $add_product_products_id . " 
AND status");
$new_price = tep_db_fetch_array($special_price);
 
if ($new_price) 
{ $product['products_price'] = $new_price['specials_new_products_price']; }
 
       //sppc patch
       //Set to false by default, configurable in the Order Editor section of the admin panel
       //thanks to whistlerxj for the original version of this patch
    
       if (ORDER_EDITOR_USE_SPPC == 'true') {
 
       // first find out the customer associated with this order ID..
            $c_id_result = tep_db_query('SELECT customers_id 
       FROM orders 
       WHERE orders_id="' . (int)$oID . '"');
 
            $cid = tep_db_fetch_array($c_id_result);
            if ($cid){
            $cust_id = $cid['customers_id'];
            // now find the customer's group.
            $c_g_id_result = tep_db_query('SELECT customers_group_id 
       FROM customers 
        WHERE customers_id="' . $cust_id . '"');
 
            $c_g_id = tep_db_fetch_array($c_g_id_result);
            if ($c_g_id){
            $cust_group_id = $c_g_id['customers_group_id'];
            // get the price of the product from the products_groups table.
            $price_result = tep_db_query('SELECT customers_group_price 
       FROM products_groups 
          WHERE products_id="' . $add_product_products_id . '" 
        AND customers_group_id="' . $cust_group_id . '"');
 
            $price_array = tep_db_fetch_array($price_result);
            if ($price_array){
            // set the price of the new product to the group specific price.
            $product['products_price'] = $price_array['customers_group_price'];
               }
              }
             }
          }
       //end sppc patch   
 
        $sql_data_array = array('orders_id' => tep_db_prepare_input($oID),
                                'products_id' => tep_db_prepare_input($add_product_products_id),
                                'products_model' => tep_db_prepare_input($product['products_model']),
                                'products_name' => tep_db_prepare_input($product['products_name']),
                                'products_price' => tep_db_prepare_input($product['products_price']),
                                'final_price' => tep_db_prepare_input(($product['products_price'] + $AddedOptionsPrice)),
                                'products_tax' => tep_db_prepare_input($products_tax),
                                'products_quantity' => tep_db_prepare_input($_POST['add_product_quantity']));
        tep_db_perform('orders_products', $sql_data_array);
        $new_product_id = tep_db_insert_id();
        
        if (isset($_POST['add_product_options'])) {
          foreach($_POST['add_product_options'] as $option_id => $option_value_id) {
            $sql_data_array = array('orders_id' => tep_db_prepare_input($oID),
                                    'orders_products_id' => tep_db_prepare_input($new_product_id),
                                    'products_options' => tep_db_prepare_input($option_names[$option_id]),
                                    'products_options_values' => tep_db_prepare_input($option_values_names[$option_value_id]),
             'options_values_price' => tep_db_prepare_input($option_value_details[$option_id][$option_value_id]['options_values_price']),
             'price_prefix' => tep_db_prepare_input($option_value_details[$option_id][$option_value_id]['price_prefix']));
            tep_db_perform('orders_products_attributes', $sql_data_array);
 
 
//add on for downloads
if (DOWNLOAD_ENABLED == 'true' && isset($filename[$option_id])) {
 
$Query = "INSERT INTO orders_products_download SET
orders_id = '" . tep_db_prepare_input($oID) . "',
orders_products_id = '" . tep_db_prepare_input($new_product_id) . "',
orders_products_filename = '" . tep_db_prepare_input($filename[$option_id]) . "',
download_maxdays = '" . tep_db_prepare_input($maxdays[$option_id]) . "',
           download_count = '" . tep_db_prepare_input($maxcount[$option_id]) . "'";
 
tep_db_query($Query);
 
        } //end if (DOWNLOAD_ENABLED == 'true') {
//end downloads 
          }
        }
 
// Update inventory Quantity
// This is only done if store is set up to use stock
if (STOCK_LIMITED == 'true'){
tep_db_query("UPDATE products SET
products_quantity = products_quantity - " . $_POST['add_product_quantity'] . " 
WHERE products_id = '" . $_POST['add_product_products_id'] . "'");
// QT Pro Addon BOF    
if (ORDER_EDITOR_USE_QTPRO == 'true') { 
        if (isset($_POST['add_product_options'])) {
        foreach($_POST['add_product_options'] as $option_id => $option_value_id) {
        $products_stock_attributes[] = $option_id . '-'. $option_value_id;
        } // for loop
        sort($products_stock_attributes, SORT_NUMERIC); // Same sort as QT Pro stock
        $products_stock_attributes = implode($products_stock_attributes, ',');
        $stock_chk_q = tep_db_query("select * from products_stock where products_id=" . $_POST['add_product_products_id']. " and products_stock_attributes='".$products_stock_attributes."'");
          $stock_chk_arr = tep_db_fetch_array($stock_chk_q);
          $new_quantity = $stock_chk_arr['products_stock_quantity'] - $_POST['add_product_quantity'];
          // update the stock
          tep_db_query("update products_stock set products_stock_quantity = ".$new_quantity." where products_id=" . $_POST['add_product_products_id']. " and products_stock_attributes='".$products_stock_attributes."'");
        }
}
// QT Pro Addon EOF
}
// Update products_ordered info
tep_db_query ("UPDATE products SET
products_ordered = products_ordered + " . $_POST['add_product_quantity'] . "
WHERE products_id = '" . $_POST['add_product_products_id'] . "'");
        
        // Unset selected product & category
        $add_product_categories_id = 0;
        $add_product_products_id = 0;
        
 
tep_redirect(tep_href_link('edit_orders_add_product.php', 'oID=' . $oID . '&step=1&submitForm=yes'));
        
break;
    }
  }
 
 
////
// Generate product list based on chosen category or search keywords
  $not_found = true;
  if (isset($_POST['search'])) {
    $search_array = explode(" ", $_POST['product_search']);
    $search_array = oe_clean_SQL_keywords($search_array);
    if (sizeof($search_array) <= 1) {
      $search_fields = array('p.products_id', 'p.products_price', 'p.products_model', 'pd.products_name');
      $product_search = oe_generate_search_SQL($search_array, $search_fields);
    } else {
      $search_fields = array('pd.products_name');
      $product_search = oe_generate_search_SQL($search_array, $search_fields, 'AND');
    }
  
    $products_query = tep_db_query("select p.products_id, p.products_price, p.products_model, pd.products_name from products p left join products_description pd on (p.products_id = pd.products_id) where pd.language_id = '" . $languages_id . "' and (" . $product_search . ") order by pd.products_name");
    $not_found = ((tep_db_num_rows($products_query)) ? false : true);
  } 
  
  if (!isset($_POST['search'])) {
    $product_search = " where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id ";
    
    $_GET['inc_subcat'] = '1';
    if ($_GET['inc_subcat'] == '1') {
      $subcategories_array = array();
      oe_get_subcategories($subcategories_array, $add_product_categories_id);
      $product_search .= " and p2c.products_id = p.products_id and p2c.products_id = pd.products_id and (p2c.categories_id = '" . (int)$add_product_categories_id . "'";
      for ($i=0, $n=sizeof($subcategories_array); $i<$n; $i++ ) {
        $product_search .= " or p2c.categories_id = '" . $subcategories_array[$i] . "'";
      }
      $product_search .= ")";
    } else {
      $product_search .= " and p2c.products_id = p.products_id and p2c.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' and p2c.categories_id = '" . (int)$add_product_categories_id . "'";
    }
 
    $products_query = tep_db_query("select distinct p.products_id, p.products_price, p.products_model, pd.products_name from products p, products_description pd, categories c, products_to_categories p2c " . $product_search . " order by pd.products_name");
    $not_found = ((tep_db_num_rows($products_query)) ? false : true);
  }
 
  $category_array = array(array('id' => '', 'text' => TEXT_SELECT_CATEGORY),
                          array('id' => '0', 'text' => TEXT_ALL_CATEGORIES));
  
  if (($step > 1) && (!$not_found)) {
    $product_array = array(array('id' => 0, 'text' => TEXT_SELECT_PRODUCT));
    while($products = tep_db_fetch_array($products_query)) {
      $product_array[] = array('id' => $products['products_id'],
                               'text' => $products['products_name'] . ' (' . $products['products_model'] . ')' . ': ' . $currencies->format($products['products_price'], true, $order->info['currency'], $order->info['currency_value']));
    }
  }
 
  $has_attributes = false;
  $products_attributes_query = tep_db_query("select count(*) as total from products_options popt, products_attributes patrib where patrib.products_id='" . (int)$add_product_products_id . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'");
  $products_attributes = tep_db_fetch_array($products_attributes_query);
  if ($products_attributes['total'] > 0) $has_attributes = true;   
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<?php if ( (isset($_GET['submitForm'])) && ($_GET['submitForm'] == 'yes') ) {
        echo '<script language="javascript" type="text/javascript"><!--' . "\n" .
             '  window.opener.document.edit_order.subaction.value = "add_product";' . "\n" . 
             '  window.opener.document.edit_order.submit();' . "\n" .
             '//--></script>';
}
?>
</head>
 
<body>
<!-- body //-->
<table border="0" width="100%" cellspacing="0" cellpadding="2">
      <tr>
        <td><table border="0" cellspacing="0" cellpadding="2" style="border: 1px solid #C9C9C9;" align="center">
          <tr class="dataTableHeadingRow">
            <td class="dataTableHeadingContent" colspan="3" align="center"><?php echo sprintf(ADDING_TITLE, $oID); ?></td>
          </tr>
          <tr class="dataTableRow">
           <form action="<?php echo tep_href_link('edit_orders_add_product.php', 'oID=' . $_GET['oID']); ?>" method="POST">
            <td class="dataTableContent" align="right"><?php echo TEXT_STEP_1; ?></td>
            <td class="dataTableContent" valign="top"><?php echo tep_draw_pull_down_menu('add_product_categories_id', tep_get_category_tree('0', '', '0', $category_array), $add_product_categories_id,'style="width:300px;" onchange="this.form.submit();"'); ?></td>
            <td class="dataTableContent" align="center">
 <noscript>
   <input type="submit" value="<?php echo TEXT_BUTTON_SELECT_CATEGORY; ?>">
 </noscript>
   <input type="hidden" name="step" value="2">
</td>
           </form>
          </tr>
          <tr class="dataTableRow">
            <td class="dataTableContent" colspan="3" align="center"><?php echo TEXT_PRODUCT_SEARCH; ?></td>
          </tr>
          <tr class="dataTableRow">
          <form action="<?php echo tep_href_link('edit_orders_add_product.php', 'oID=' . $_GET['oID']); ?>" method="POST">
            <td> </td>
            <td class="dataTableContent" valign="top"> <input type="text" name="product_search" value="<?php if(isset($_POST['product_search'])) echo $_POST['product_search']; ?>" onchange="this.form.submit();">
</td>
            <td class="dataTableContent" align="center"><noscript><input type="submit" value="Search for This Product"></noscript><input type="hidden" name="step" value="2"><input type="hidden" name="search" value="1"></td>
          </form>
          </tr>
        <?php if ($not_found) { ?>
          <tr class="dataTableRow">
            <td class="dataTableContent" colspan="3" align="center"><?php echo TEXT_PRODUCT_NOT_FOUND; ?></td>
          </tr>
        <?php } ?>
<?php
  if (($step > 1) && (!$not_found)) {
    echo '          <tr class="dataTableRow">' . "\n" .
         '            <td colspan="3" style="border-bottom: 1px solid #C9C9C9;">' . tep_draw_separator('pixel_trans.gif', '1', '1') . '</td>' . "\n" .
         '          </tr>' . "\n" .
         '          <tr class="dataTableRow">' . "\n" .
         '            <td colspan="3" style="background: #FFFFFF;">' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td>' . "\n" .
         '          </tr>' . "\n";
?>
          <tr class="dataTableRow"> 
            <td colspan="3" style="border-top: 1px solid #C9C9C9;"><?php echo tep_draw_separator('pixel_trans.gif', '1', '1'); ?></td>
          </tr>
          <tr class="dataTableRow">
          <form action="<?php echo tep_href_link('edit_orders_add_product.php', 'oID=' . $_GET['oID']); ?>" method="POST">
            <td class="dataTableContent" align="right"><?php echo TEXT_STEP_2; ?></td>
            <td class="dataTableContent" valign="top"><?php echo tep_draw_pull_down_menu('add_product_products_id', $product_array, $add_product_products_id, 'style="width:300px;" onchange="this.form.submit();"'); ?></td>
            <td class="dataTableContent" align="center"><noscript><input type="submit" value="<?php echo TEXT_BUTTON_SELECT_PRODUCT; ?>"></noscript><input type="hidden" name="step" value="3">
            <input type="hidden" name="add_product_categories_id" value="<?php echo $add_product_categories_id; ?>">
          <?php if (isset($_POST['search'])) { ?>
            <input type="hidden" name="search" value="1">
            <input type="hidden" name="product_search" value="<?php echo $_POST['product_search']; ?>">
          <?php } ?>
            </td>
          </form>
          </tr>
<?php
  }
 
  if (($step > 2) && ($add_product_products_id > 0)) {
    echo '          <tr class="dataTableRow">' . "\n" .
         '            <td colspan="3" style="border-top: 1px solid #C9C9C9;">' . tep_draw_separator('pixel_trans.gif', '1', '1') . '</td>' . "\n" .
         '          </tr>' . "\n" .
         '          <tr class="dataTableRow">' . "\n";
    
    if ($has_attributes) echo '          <form action="' . tep_href_link('edit_orders_add_product.php', 'oID=' . $_GET['oID']) . '" method="post">' . "\n";
 
    echo '            <td class="dataTableContent" align="right">' . TEXT_STEP_3 . '</td>' . "\n";
 
    if ($has_attributes) {
      $i=1;
      $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from products_options popt, products_attributes patrib where patrib.products_id='" . (int)$add_product_products_id . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . $languages_id . "'");
      while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
        $selected = 0;
        $products_options_array = array();
        if ($i > 1) echo '            <td class="dataTableContent"> </td>' . "\n";
        $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from products_attributes pa, products_options_values pov where pa.products_id = '" . (int)$add_product_products_id . "' and pa.options_id = '" . $products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "'");
        while ($products_options = tep_db_fetch_array($products_options_query)) {
          $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options_name['products_options_name'] . ' - ' . $products_options['products_options_values_name']);
          if ($products_options['options_values_price'] != '0') {
            $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->format($products_options['options_values_price'], true, $order->info['currency'], $order->info['currency_value']) .')';
          }
        }
 
if(isset($_POST['add_product_options'])) {
          $selected_attribute = $_POST['add_product_options'][$products_options_name['products_options_id']];
        } else {
          $selected_attribute = false;
        }
 
        echo   '            <td class="dataTableContent" valign="top">' . tep_draw_pull_down_menu('add_product_options[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute) . '</td>' . "\n" .
               '            <td class="dataTableContent"> </td>' . "\n" .
               '          </tr>' . "\n" .
               '          <tr class="dataTableRow">' . "\n";  
        $i++;
      }
      echo '            <td class="dataTableContent"> </td>' . "\n" .
           '            <td class="dataTableContent" colspan="2" align="left"><input type="submit" value="' . TEXT_BUTTON_SELECT_OPTIONS . '"><input type="hidden" name="step" value="4"><input type="hidden" name="add_product_categories_id" value="' . $add_product_categories_id . '"><input type="hidden" name="add_product_products_id" value="' . $add_product_products_id . '">' . ((isset($_POST['search'])) ? '<input type="hidden" name="search" value="1"><input type="hidden" name="product_search" value="' . $_POST['product_search'] . '">' : '') . '</td>' . "\n" .
           '          </tr>' . "\n" .
           '          </form>' . "\n";
    } else {
      $step = 4;
      echo '            <td class="dataTableContent" valign="top" colspan="2">' . TEXT_SKIP_NO_OPTIONS . '</td>' . "\n" .
           '          </tr>' . "\n";
    }
  }
  
  if ($step > 3) {
    echo '          <tr class="dataTableRow">' . "\n" .
         '            <td colspan="3" style="border-bottom: 1px solid #C9C9C9;">' . tep_draw_separator('pixel_trans.gif', '1', '1') . '</td>' . "\n" .
         '          </tr>' . "\n" .
         '          <tr class="dataTableRow">' . "\n" .
         '            <td colspan="3" style="background: #FFFFFF;">' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td>' . "\n" .
         '          </tr>' . "\n" .
         '          <tr class="dataTableRow">' . "\n" .
         '            <td colspan="3" style="border-top: 1px solid #C9C9C9;">' . tep_draw_separator('pixel_trans.gif', '1', '1') . '</td>' . "\n" .
         '          </tr>' . "\n" .
         '          <form action="' . tep_href_link('edit_orders_add_product.php', 'oID=' . $_GET['oID'] . '&action=add_product') . '" method="post">' . "\n" .
         '          <tr class="dataTableRow">' . "\n" .
         '            <td class="dataTableContent" align="right" valign="middle">' . TEXT_STEP_4 . '</td>' . "\n" .
         '            <td class="dataTableContent" align="left" valign="middle">' . TEXT_QUANTITY . ' <input name="add_product_quantity" size="3" value="1"></td>' . "\n" .
         '            <td class="dataTableContent" align="center" valign="middle"></td>' . "\n" .
'          </tr>' . "\n" . 
'          <tr class="dataTableRow">' . "\n" .
'             <td></td>' . "\n" . 
'             <td colspan="2"><input type="submit" value="' . TEXT_BUTTON_ADD_PRODUCT .'">' . "\n" .
'           ';
    if (isset($_POST['add_product_options'])) {
      foreach($_POST['add_product_options'] as $option_id => $option_value_id) {
        echo '<input type="hidden" name="add_product_options['.$option_id.']" value="' . $option_value_id . '">';
      }
    }
    echo '<input type="hidden" name="add_product_categories_id" value="' . $add_product_categories_id . '"><input type="hidden" name="add_product_products_id" value="' . $add_product_products_id . '"><input type="hidden" name="step" value="5"></td>' . "\n" .
         '          </tr>' . "\n" .
         '          </form>' . "\n";
  }
?>
        </table></td>
      </tr>
    </table>
    <!-- body_text_eof //-->
 
           <div align="center" class="dataTableContent">
                   
  <script language="JavaScript" type="text/javascript">
                   <!--
                    document.write("<a href=\"javascript:self.close();\"><?php echo TEXT_CLOSE_POPUP; ?></a>");
              //-->
                  </script>
 
 <noscript>
  <strong>
   <?php echo TEXT_ADD_PRODUCT_INSTRUCTIONS; ?>
                   </strong>
 </noscript>
 
  </div>
      
 
<!-- body_eof //-->
 
</body>
</html>
<?php  //eof   ?>

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

×