Jump to content
Sign in to follow this  
Maryw

Ajax Order Editor

Recommended Posts

I just installed and tested the nice Ajax Order Editor contribution today. I want to have this feature implemented on my store's front end too. That is to add the products directly from the Ajax search suggest results list to the shopping cart without refreshing the page. Can this be easily converted?

 

I wonder if it is possible to have no page refreshing in the entire process? Right now a page refreshing is required after delete an order and before add a new product to the order.

 

Also I wonder if it is possible to put the "add product confirm button" right at the end of each product on the ajax search suggest result list, so that when clicking on it the product is automatically added to the order?

 

Thank you.

Share this post


Link to post
Share on other sites

I am sorry, I dont know anything about AJAX.

 

I downloaded this contribution and read through it -

 

Does this contribution mean that I dont need to make any adjustments/additions such as adding tables etc... to mysql database like the other order editor ?

 

What are the benefits of AJAX ?

Share this post


Link to post
Share on other sites

hi sheepiedog,

AJAX make possible changing stuff in the database without loading a new page. Among other things.

In this case, you can edit anything of your client's orders directly from the orders.php screen: for example, you clic on the name and appears a prompt. In this promt you put the correct name, hit the enter key and that's it, the name has changed. You'll see a alert that confirms it to you. If you want to see the changed name, you'll have to reload (F5) the page. But that's not necesary: reload is just to see, changes are kept in the db anyway

And yes, that's right, this contribution doesn't change anything in the database, there is no *.sql file.

Install it and try it, you'll love it :thumbsup:

 

Maryw:

I'm not sure understanding you right.

For the your front end, you should try theAJAX Buy Now contribution.

If your other questions are about my contrib, please explain better.

 

See you

ledave

Share this post


Link to post
Share on other sites

Leadave I have a problem...

i've just installed your AJAX ORDER EDITOR (during the installation "replacing" were everything fine), but after upload all files it's not working.

Explain of this:

My Order.php not loading (Just white screen) and no error text, just nothing :/

 

Also i tried to copy your (with your ajax mod) files, but only what changed is:

Fatal error: Call to undefined function tep_admin_check_login() in /home/moana/public_html/sklep-nurkowy/admin/includes/application_top.php on line 212

 

when i hash this function in application_top.php there was still the same blank screen :/

 

I think it could be problem general.php... maybe some function in a file may not be loaded... but it's only my thoughts

 

Do u have any solution with this?

 

PS i use follows contributions:

Ultimate_SEO_URLsv21da_1_2

search_enhancements_v1.1a_1

Who's Online Enhancement 2.0ec full package by Graphicore

ship2pay-2.01

Share this post


Link to post
Share on other sites

I also installed the order editor tool today, it sounded ideal for my purposes but I have the following error on trying to load the orders.php page in admin.

 

Fatal error: Cannot use string offset as an array in /home/mysite/public_html/os/admin/includes/classes/table_block.php on line 67

 

At the top of the page is the following 2 lines then the error message below it, so I assume it is trying to load correctly

 

Add a product

Name or model of product:

 

All updates to the files in question went smoothly, unless I missed a step, but I double checked and found nothing amiss. ANy idea what might be the problem?

Share this post


Link to post
Share on other sites

i found something in orders.php to my problem of empty sceen

in this part:

<div id="add-Product" class="addProduct">

<div><?php echo DIV_ADD_PRODUCT_HEADING; ?></div>

<div id="add-product-product" class="addProductContents"><?php echo ADD_PRODUCT_SELECT_PRODUCT; ?></div>

<div id="addProductSearch" class="addProductContentsSearch"><?php include (DIR_WS_INCLUDES . 'advanced_search.php'); ?></div>

<div id="addProductFind"> </div>

<div id="ProdAttr"> </div>

<a href="java script: hideAddProducts();"><?php echo tep_image(DIR_WS_LANGUAGES . $language . '/images/buttons/button_cancel.gif'); ?></a>

</div>

When I erased line:

<div id="addProductSearch" class="addProductContentsSearch"><?php include (DIR_WS_INCLUDES . 'advanced_search.php'); ?></div>

The orders.php displays correctly but without installed ajax editor. So I think it does sth...

Share this post


Link to post
Share on other sites

Hi guys,

arwo,

the line that gives you problem is the one that includes the advanced_search.php file. You'd check every part of that line: is the class addProductContentsSearch defined in the stylesheet, is the advanced_search.php in your admin/includes folder, does the variable DIR_WS_INCLUDES (in your configure.php) points out to the folder where you have the advanced_search.php file

 

gardenho,

it seems that there is something wrong at the begining of the html code of your orders.php file. Paste here the lines of the div's that you added with my contribs, with 10 lines before, and 10 lines after, so I can have a look at it.

 

see you, and thanks for your interest in my contrib :)

Share this post


Link to post
Share on other sites
gardenho,

it seems that there is something wrong at the begining of the html code of your orders.php file. Paste here the lines of the div's that you added with my contribs, with 10 lines before, and 10 lines after, so I can have a look at it.

 

Thanks for the quick response, much appreciated. Below I've pasted the code from the top of admin/orders.php with 10 below and above as requested:

 

  include(DIR_WS_CLASSES . 'order.php');
?>
<!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">
<script language="javascript" src="includes/general.js"></script>
<script language="javascript" src="includes/ajax.js"></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<div id="add-Product" class="addProduct">
<div><?php echo DIV_ADD_PRODUCT_HEADING; ?></div>
<div id="add-product-product" class="addProductContents"><?php echo ADD_PRODUCT_SELECT_PRODUCT; ?></div>
<div id="addProductSearch" class="addProductContentsSearch"><?php include (DIR_WS_INCLUDES . 'advanced_search.php'); ?></div>
<div id="addProductFind"> </div>
<div id="ProdAttr"> </div>
<a href="java script: hideAddProducts();"><?php echo tep_image(DIR_WS_LANGUAGES . $language  . '/images/buttons/button_cancel.gif'); ?></a>
</div>
<!-- header //-->
<?php
 require(DIR_WS_INCLUDES . 'header.php');
?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
 <tr>
<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">

 

Looking forward to your response - also just noticed in Dreamweaver, the line I pasted from your code below is highlighted as an invalid markup unclosed tag/overlapping. Could that be part of the problem at all? In comparing it to all the other updateorerfield lines it does have the closing tags in a diff. order?

 

<snip>

<td class="main"><a href="java script: updateOrderField('<?php echo $oID; ?>', 'orders', 'customers_email_address', '<?php echo $order->customer['email_address']; ?>');" class="ajaxLink"><?php echo $order->customer['email_address'] . '</a>'; ?></td>

<snip>

Share this post


Link to post
Share on other sites

I'm confused, I don't understand where is the problem :huh:

The only thing it occurs to me is the damn Dreamweaver. I barely know it but does know that he add code we don't want to.

Could you zip and upload your entire orders.php file in a place I can download it so I can have a look at it?

 

Regarding the </a> in the <?php echo $order->customer['email_address'] . '</a>'; ?>, it makes no diference, but you can place it like this: <?php echo $order->customer['email_address']; ?></a> in order to keep the same appearance as the others.

Share this post


Link to post
Share on other sites

hi LEADVE

listen up :] this what u said was true, the mistake was in orders.php

<div id="addProductSearch" class="addProductContentsSearch"><?php include (DIR_WS_INCLUDES . 'advanced_search.php'); ?></div>

exactly in DIR_WS_INCLUDES, i dont have advanced_search.php in includes folder. i have it in main folder.

i changed href to this file and orders.php appears correctly, but without the ajax! ...

 

One more thing i matched is i dont have a defined style class="addProductContentsSearch" in stylesheet.css in admin folder :/

Can u send me or write here your defined class for this? (maybe it the reason why the ajax isnt visible in my Firefox)

 

THx

Yo!

Share this post


Link to post
Share on other sites

hi arwo,

well, I've forgotten the stylesheet.css. sorry about that.

You should add this, in your admin/includes/stylesheet.css

/* AJAX Orders Editor */
a.ajaxLink { font-family: Verdana, Arial, sans-serif; font-size: 12px; text-decoration: underline}
.addProduct {
width: 400px;
height: 400px
border: solid;
display: none;
position: absolute;
background-color: #B3BAC5;
border-color: #f9b85c;
font-family: Verdana, Arial, sans-serif;
}

.addProductContents {
background-color: #C9C9C9;
font-family: Verdana, Arial, sans-serif;
font-size: 10px;
color: #ffffff;
font-weight: bold;
}

and that will make the trick and make visible the search product field.

If you want, I've just uploaded version 1.1 wich allow you to create orders_toal field in the order.

Let me know how it's going now.

see you

Share this post


Link to post
Share on other sites

Hello David, I just installed your contribution and I think its really nice.

 

I got two question though and there wasnt an official topic so I thought I could post it here.

On the site im building at the moment I got downloads but when you add a product from the order page it wont give the customer a new download link.

 

The other question isnt that important but when your in the ordering page you will just get a , in front of the country name if the state isnt filled in (normally it shows just the country without the ,) I tried to remove it but then its not possible to change the state if the customer had a state.

The code that will show this is in admin/includes/functions/general.php:

 $state = (($ajax != '') ? '<a href="java script: updateOrderField(\'' . $order_id . '\', \'orders\', \'' . $ajax . 'state\', \'' . tep_output_string_protected($address['state']) . '\');" class="ajaxLink">' : '') . tep_output_string_protected($address['state']) . (($ajax != '') ? '</a>' : '');

 

Other then that its really a nice contribution, thanks :)

Edited by Dennis_gull

Share this post


Link to post
Share on other sites

hi Dennis_gull,

about the coma before the empty state, in your catalog/admin/includes/functions/general.php, line 402 change

if ($state != '') $statecomma = $state . ', ';

to

if ($address['state'] != '') $statecomma = $state . ', ';

About the downloads, the thing is I've never use them, so I don't know how they works. I suppose that you have to put a new entry in orders_products_downloads, if one of the products_attributes is in the products_attributes_download table.

So in the catalog/admin/orders_ajax.php file you should, replace (158-179):

for ($j=0; $j<sizeof($attributes); $j++) {
		  $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . $products_id . "' and options_id = '" . $attributes[$j][0] . "' and options_values_id = '" . $attributes[$j][1] . "'");
		  $attribute_price = tep_db_fetch_array($attribute_price_query);
		  if ($attribute_price['price_prefix'] == '+') {
			  $attribute_price_sum += (float)$attribute_price['options_values_price'];
		  } else {
			  $attribute_price_sum -= (float)$attribute_price['options_values_price'];
		  }
		  $attribute_name_query = tep_db_query("select products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . $attributes[$j][0] . "' and language_id = '" . (int)$languages_id . "'");
		  $attribute_name = tep_db_fetch_array($attribute_name_query);
		  $options_name_query = tep_db_query("select products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . $attributes[$j][1] . "' and language_id = '" . (int)$languages_id . "'");
		  $options_name = tep_db_fetch_array($options_name_query);

		  tep_db_query("insert into " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " (orders_id, orders_products_id, products_options, products_options_values, options_values_price, price_prefix) values ('" . $orders_id . "', '0', '" . tep_db_input((string)$attribute_name['products_options_name']) . "', '" . tep_db_input((string)$options_name['products_options_values_name']) . "', '" . tep_db_input((float)$attribute_price['options_values_price']) . "', '" . tep_db_input((string)$attribute_price['price_prefix']) . "')");
	  }
  }
  $final_price = (float)$product_info['products_price'] + (float)$attribute_price_sum;
  tep_db_query("insert into " . TABLE_ORDERS_PRODUCTS . " (orders_id, products_id, products_model, products_name, products_price, final_price, products_tax, products_quantity) values ('" . $orders_id . "', '" . $products_id . "', '" . $product_info['products_model'] . "', '" . $product_info['products_name'] . "', '" . $product_info['products_price'] . "', '" . $final_price . "', '" . $tax . "', '" . $products_quantity . "')");
  $orders_products_id = tep_db_insert_id();
  if ($attribute_update == true){
	  tep_db_query("update  " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " set orders_products_id = '" . $orders_products_id . "' where orders_products_id = '0'");
  }

by

for ($j=0; $j<sizeof($attributes); $j++) {
		  $attribute_price_query = tep_db_query("select products_attributes_id, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . $products_id . "' and options_id = '" . $attributes[$j][0] . "' and options_values_id = '" . $attributes[$j][1] . "'");
		  $attribute_price = tep_db_fetch_array($attribute_price_query);
		  if ($attribute_price['price_prefix'] == '+') {
			  $attribute_price_sum += (float)$attribute_price['options_values_price'];
		  } else {
			  $attribute_price_sum -= (float)$attribute_price['options_values_price'];
		  }
		  $attribute_name_query = tep_db_query("select products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . $attributes[$j][0] . "' and language_id = '" . (int)$languages_id . "'");
		  $attribute_name = tep_db_fetch_array($attribute_name_query);
		  $options_name_query = tep_db_query("select products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . $attributes[$j][1] . "' and language_id = '" . (int)$languages_id . "'");
		  $options_name = tep_db_fetch_array($options_name_query);

		  tep_db_query("insert into " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " (orders_id, orders_products_id, products_options, products_options_values, options_values_price, price_prefix) values ('" . $orders_id . "', '0', '" . tep_db_input((string)$attribute_name['products_options_name']) . "', '" . tep_db_input((string)$options_name['products_options_values_name']) . "', '" . tep_db_input((float)$attribute_price['options_values_price']) . "', '" . tep_db_input((string)$attribute_price['price_prefix']) . "')");

		  //check for downloads
		  $download_query = tep_db_query("select * from " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " where products_attributes_id = '" . (int)$attribute_price['products_attributes_id'] . "'");
		  if (tep_db_num_rows($download_query)) {
			  $download = tep_db_fetch_array($download_query);
			  tep_db_query("insert into " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " (orders_id, orders_products_id, orders_products_filename, download_maxdays, download_count) values ('" . $orders_id . "', '0', '" . tep_db_input((string)$download['products_attributes_filename']) . "', '" . tep_db_input((int)$download['products_attributes_maxdays']) . "', '" . tep_db_input((int)$download['products_attributes_maxcount']) . "')");
		  }
	  }
  }
  $final_price = (float)$product_info['products_price'] + (float)$attribute_price_sum;
  tep_db_query("insert into " . TABLE_ORDERS_PRODUCTS . " (orders_id, products_id, products_model, products_name, products_price, final_price, products_tax, products_quantity) values ('" . $orders_id . "', '" . $products_id . "', '" . $product_info['products_model'] . "', '" . $product_info['products_name'] . "', '" . $product_info['products_price'] . "', '" . $final_price . "', '" . $tax . "', '" . $products_quantity . "')");
  $orders_products_id = tep_db_insert_id();
  if ($attribute_update == true){
	  tep_db_query("update  " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " set orders_products_id = '" . $orders_products_id . "' where orders_products_id = '0'");
	  tep_db_query("update  " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " set orders_products_id = '" . $orders_products_id . "' where orders_products_id = '0'");
  }

please confirm it's working fine so I can upload as version 1.2 :)

Share this post


Link to post
Share on other sites

Hello again, I tried the new code and it worked but not if you have the group file contribution enabled.

It then add a new download but it doesn't give the download link, it still says "you have 5 downloads remaining" and it also show when the link expires.. But I can probably figure out a way to fix that :)

 

PS:

 

The coma fix worked :)

Edited by Dennis_gull

Share this post


Link to post
Share on other sites

hi Leadave

Sory for not being here for few days (i had a lot of work at my university :/

Well... Your Stylesheet rather working fine :]

Now i have other problems... I think they are only two:

1) When i click to add a product, show up a new box (with adding) and below the server error message:

 

Add a product

Name or model of product:

 

Warning: include(/includes/advanced_search.php) [function.include]: failed to open stream: No such file or directory in /home/moana/public_html/sklep_test/admin/orders.php on line 106

 

Warning: include() [function.include]: Failed opening '/includes/advanced_search.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/moana/public_html/sklep_test/admin/orders.php on line 106

 

!advanced_search.php is in includes folder! i'm sure

the line 106 in orders looks like this:

<div id="addProductSearch" class="addProductContentsSearch"><?php include ('/includes/advanced_search.php'); ?></div>

 

What's wrong with it?

 

And the second problem i will write down other time :] (i added netto price without a tax in order class, and it has influence at calculating final price in your ajax editor, It makes just like it now: netto+brutto+shipping=final_price <-it's wrong, because should be brutto+shipping=final_price :/

But as i said it's the other story... :]

 

Cya!

 

Thanks for being patient! ;]

Share this post


Link to post
Share on other sites

Hi Arwo,

I guess the problem is the / at the beginning of the includes/

Try changing this line by:

<div id="addProductSearch" class="addProductContentsSearch"><?php include (DIR_WS_INCLUDES . 'advanced_search.php'); ?></div>

About the tax, I've never use them myself, so it's more likely that some things doesn't work fine. Explain the problem and will try to find a solution.

cu

Share this post


Link to post
Share on other sites

I have to a problem with the Ajax Orders Edit. My problem is, that after the installtion I become an error because of this:

 

Fatal error: Cannot use string offset as an array in C:\www\videowelten\admin\includes\classes\table_block.php on line 67

 

I don't know what can be wrong with my orders.php in the Admin interface. What I had do was with WinMerg to compare the orders.php from the contrib an my hey are at the code changes the same. After that I have checked this with my copy of the orders.php and anywhere who where create the table there is no mistake or like this.

Share this post


Link to post
Share on other sites

Hi bluepower2010,

I'm not sure understanding you well, but it's the same problem as gardenho.

Try this shot: replace your admin/includes/advanced_search.php by this:

<?php
 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ORDERS);
 $info_box_heading = array();
 $info_box_contents = array();

 $info_box_contents[] = array('text' => tep_draw_input_field('keywords',
														  '',
														  'id="keywords" onKeyUp="loadXMLDoc(this.value);" autocomplete="off" style="width: 100%"'));
 $info_box_contents[] = array('text' => '<div style="display: block; margin-left: 0%; width:100%; float: left; border:solid 1px; background-color:#CCCCCC;" id="quicksearch">' . PRODUCTS_SEARCH_RESULTS . '</div>');

 $box = new box;
 echo $box->infoBox($info_box_heading, $info_box_contents);
?>

and please get back to me either it's working or not.

Share this post


Link to post
Share on other sites

hi ledave

with DIR_WS_INCLUDES is still doesn't work :/

when i add this i have just empty "orders.php" window :/

everything appears only with "/includes/advanced.php"

 

but simply code in the same file few lines below:

<?php

require(DIR_WS_INCLUDES . 'header.php');

?>

works fine :/

i dont f* know what can it be...

Share this post


Link to post
Share on other sites

have you tried:

<div id="addProductSearch" class="addProductContentsSearch"><?php include ('includes/advanced_search.php'); ?></div>

Otherwise, if the code says that he cannot find the advanced_search.ph in the includes folder, you can trust him, the file isn't in the folder.

Maybe in the catalog/includes/...

Share this post


Link to post
Share on other sites

@ ledave

 

Okay, your tip had help me with my problem. But now I have the same problem how arow. I have the adanced_search in the includes directory at the admin and the catalog, but at anyplace the ajax script give me an error 404 code and the url 192.168.1.3. as server. That ip adress is my home server ip but the ip is not with the direcotry after the ip adress who the server found the shop.

 

Can it be, because I use php5 and not php4?

Share this post


Link to post
Share on other sites

well, I don't know why, but this way should work: in your orders.php, replace

<div id="add-Product" class="addProduct">
<div><?php echo DIV_ADD_PRODUCT_HEADING; ?></div>
<div id="add-product-product" class="addProductContents"><?php echo ADD_PRODUCT_SELECT_PRODUCT; ?></div>
<div id="addProductSearch" class="addProductContentsSearch"><?php include (DIR_WS_INCLUDES . 'advanced_search.php'); ?></div>
<div id="addProductFind"> </div>
<div id="ProdAttr"> </div>
<a href="java script: hideAddProducts();"><?php echo tep_image(DIR_WS_LANGUAGES . $language  . '/images/buttons/button_cancel.gif'); ?></a>
</div>

by

<div id="add-Product" class="addProduct">
<div><?php echo DIV_ADD_PRODUCT_HEADING; ?></div>
<div id="add-product-product" class="addProductContents"><?php echo ADD_PRODUCT_SELECT_PRODUCT; ?></div>
<div id="addProductSearch" class="addProductContentsSearch">
<?php
 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ORDERS);
 $info_box_heading = array();
 $info_box_contents = array();

 $info_box_contents[] = array('text' => tep_draw_input_field('keywords',
														  '',
														  'id="keywords" onKeyUp="loadXMLDoc(this.value);" autocomplete="off" style="width: 100%"'));
 $info_box_contents[] = array('text' => '<div style="display: block; margin-left: 0%; width:100%; float: left; border:solid 1px; background-color:#CCCCCC;" id="quicksearch">' . PRODUCTS_SEARCH_RESULTS . '</div>');

 $box = new box;
 echo $box->infoBox($info_box_heading, $info_box_contents);
?>
</div>
<div id="addProductFind"> </div>
<div id="ProdAttr"> </div>
<a href="java script: hideAddProducts();"><?php echo tep_image(DIR_WS_LANGUAGES . $language  . '/images/buttons/button_cancel.gif'); ?></a>
</div>

so you don't include it anymore, the code is in the same file.

Let's see if it's a include problem, or of my code.

Tell me something when you can.

see you

Share this post


Link to post
Share on other sites

I don't know what the problem is but I send you the problem wich the scrip me said.

 

I don't know why the script always use only the ip and not the directory in the error 404

 

fehler.jpg

 

The same error I will become an my server.

 

The Script also is the best that I found but this error is ..... and I will be crazy at the moment, because I don't find anything wich the error can be.

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
Sign in to follow this  

×