Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Ajax Order Editor


Maryw

Recommended Posts

Thank you very much for the Order Editor, it solves a big problem we had, we sell meat by the Kg and need to alter the order to put in the exact weight of the product sold, after we have cut it and weighed it.

THE PROBLEM IS: We can only change the weight by altering the quantity, and the quantity rounds off to a single unit when we update.

THE SOLUTION: would be to allow quantity with decimals after update or allow us to change the weight.

How can I make these changes?

Thank you

Michael

Link to comment
Share on other sites

  • Replies 110
  • Created
  • Last Reply

Top Posters In This Topic

Hi,

 

Sure seems like a wonderful contrib ( didn't get the chance to use it yet... :)

 

I get this message when trying to enter the admin after installation:

 

Parse error: parse error, unexpected ':' in /admin/includes/functions/general.php on line

 

It refers to the RED line:

 

 

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

 

 

from the following code:

 

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

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 = (($ajax != '') ? '<a href="java script: updateOrderField(\'' . $order_id . '\', \'orders\', \'' . $ajax . 'name\', \'' . addslashes(tep_output_string_protected($address['name'])) . '\');" class="ajaxLink">' : '') . tep_output_string_protected($address['name']) . (($ajax != '') ? '</a>' : '');

$lastname = '';

} else {

$firstname = '';

$lastname = '';

}

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

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

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

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

if (isset($address['country_id']) && tep_not_null($address['country_id'])) {

$country = tep_get_country_name($address['country_id']);

 

 

 

pleeeeeeeese help, i have tried several changes but nothing, i need a lead...

 

Thanks!

Installed contributions:

Ultimate_SEO, Article Manager 1.5, Dynamic SiteMap 2.0, Infopages, Google SiteMap XMl w/admin 2.1, HeaderTagControler 2.6.1, FCKosc 2.21, X-sell 2.3, Google Analytics Modul, All Products, Page Cache 1.5, EasyPopulate2.7d, Multi Product Manager 2.5, Define Main Page, and probably few others...

Link to comment
Share on other sites

hi mck,

for having decimals as your products_quantity, you should just change the type of data of this column in the database (products table).

However, in your case it would be better to add th weight field and make it editable: I can't help you with this, but if you look at the code you could do it.

 

hi sukarya,

this should work:

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

Link to comment
Share on other sites

hi sukarya,

this should work:

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

 

 

Worked, thanks.

 

Great Contrib Man!

Installed contributions:

Ultimate_SEO, Article Manager 1.5, Dynamic SiteMap 2.0, Infopages, Google SiteMap XMl w/admin 2.1, HeaderTagControler 2.6.1, FCKosc 2.21, X-sell 2.3, Google Analytics Modul, All Products, Page Cache 1.5, EasyPopulate2.7d, Multi Product Manager 2.5, Define Main Page, and probably few others...

Link to comment
Share on other sites

craxx, in order to keep the french forum in french, I answer you here.

The code you spoke about is just to have indicated when you add a product if it has stock or no, integrating QTpro.

 

Here it is:

in admin/includes/ajax.js, add those 2 fonctions:

function check_stock() {
var atributo = '';
for (var i=0; i<document.attributes.elements.length; i++) {
	if (document.attributes.elements[i].name.indexOf('atrid_') == 0) {
		atributo += ((atributo == '') ? '' : ',') + document.attributes.elements[i].name.substring(6)+'-'+document.attributes.elements[i].value;
	}
}
var url = "orders_ajax.php?action=check_stock&prID=" + document.attributes.products_id.value + "&atr=" + atributo;
createRequest();
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = StateChangeStock;
xmlHttp.send(null);
}

function StateChangeStock() {
if(xmlHttp.readyState == 4) {
	document.getElementById("checkStock").innerHTML = xmlHttp.responseText;
}
}

Then in admin/orders_ajax.php, line 171, after

if ($products_attributes['total'] > 0) {

add

$check_stock = '';

Line 183, replace

$attributes .= '<tr><td class="main">' . $products_options_name['products_options_name'] . ':</td><td class="main">' . tep_draw_pull_down_menu('atrid_' . $products_options_name['products_options_id'], $products_options_array, $selected_attribute) . '</td></tr>';

with

$attributes .= '<tr><td class="main">' . $products_options_name['products_options_name'] . ':</td><td class="main">' . tep_draw_pull_down_menu('atrid_' . $products_options_name['products_options_id'], $products_options_array, $selected_attribute, 'onchange=check_stock()') . '</td></tr>';
		  $check_stock .= (($check_stock == '') ? '' : ',') . $products_options_name['products_options_id'] . '-' . $products_options_array[0]['id'];

and line 185, just before

$attributes .= '<tr><td colspan="2">' . tep_image_submit('button_confirm.gif', IMAGE_CONFIRM) . '</td></tr></table></form>';

add

$check_stock_query = tep_db_query("select products_stock_id from " . PRODUCTS_STOCK . " where products_id = '" . (int)$HTTP_GET_VARS['prID'] . "' and products_stock_attributes = '" . $check_stock . "' and products_stock_quantity > '0'");
	  $attributes .= '<tr><td colspan="2" id="checkStock">' . ((!tep_db_num_rows($check_stock_query)) ? 'This option is not available.' : ' ') . '</td></tr>';

And finally, just before the las ?>, add

 elseif ($action == 'check_stock') {
  $check_stock_query = tep_db_query("select products_stock_id from " . PRODUCTS_STOCK . " where products_id = '" . (int)$HTTP_GET_VARS['prID'] . "' and products_stock_attributes = '" . $HTTP_GET_VARS['atr'] . "' and products_stock_quantity > '0'");
  echo ((!tep_db_num_rows($check_stock_query)) ? 'This option is not available.' : ' ');
 }

That's it.

 

But I repeat, I'm not planning to update stocks in this contrib, it would be very heavy. The easiest way to do it, I think, is to update when you send the order.

 

cheers

Edited by ledave
Link to comment
Share on other sites

First of all..thanks for a great contrib.

 

And second..I can't add products with it. Everything else works just fine.

I've tried with both FF2.0 and IE6.

 

I get the popup when I click on Add product. I start typing but nothing happens. No searchresults or anything.

I've also tried to comment out xmlHttp.onreadystatechange as Freeman suggested, but with no results.

 

I have 14k products in my shop. Could this affect the functionality of the script?

 

Any help would be appreciated.

Link to comment
Share on other sites

hi rajonbh,

glad you like it :thumbsup:

 

Do you have the admin acces contrib installed? You have to autorized the orders_ajax.php file.

 

I guess that's why it's not working. If that doesn't work we'll look into it.

 

cheers

Link to comment
Share on other sites

okay,

it seems that your catalog/includes/advanced_search.php is wrong, it should be like this:

<?php
 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ORDERS);
 $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_contents);
?>

yours is missing the id="keywords"

tell me how it's working now

Link to comment
Share on other sites

Still didn't work, and id="keywords" didn't show up now either.

But I got it working now..finally :)

I had to adjust the function tep_draw_input_field, cause it didn't write the parameters for the input field.

 

Thanks for the quick help.

Link to comment
Share on other sites

PHP5 COMPATIBILITY

 

I've just upgrade to php5 and have had a compatibility problem.

The solution is changing the admin/includes/advanced_search.php by:

<?php
 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ORDERS);
 $heading[] = array('text'  => '');
 $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($heading, $info_box_contents);
?>

Hope it can help someone.

Link to comment
Share on other sites

  • 3 months later...
PHP5 COMPATIBILITY

 

I've just upgrade to php5 and have had a compatibility problem.

The solution is changing the admin/includes/advanced_search.php by:

<?php
 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ORDERS);
 $heading[] = array('text'  => '');
 $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($heading, $info_box_contents);
?>

Hope it can help someone.

Link to comment
Share on other sites

PHP5 COMPATIBILITY

 

I've just upgrade to php5 and have had a compatibility problem.

The solution is changing the admin/includes/advanced_search.php by:

<?php
 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ORDERS);
 $heading[] = array('text'  => '');
 $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($heading, $info_box_contents);
?>

Hope it can help someone.

 

Sorry about my error in replying. I was using order editor I believe ver 2.0 and it was way to slow when editing large orders. I installed this contribution and it works great on my details page but if I touch the order editor which has a few features I need for some orders it doubles the order in admin and everything from sub total on down gets doubled if you hit update on order editor. Will this not work along side with that or is there a fix someone knows of. Thanks

Link to comment
Share on other sites

First off.. GREAT contribution.

 

This function should be a "standard" in OSC though.

 

Thx for the PHP5 fix, it really helped me when we moved servers.

 

I have 1 problem though.

 

When i add products via the "Ajax Order Editor" with the Ajax Search.

 

I takes a weird cost price. It adds 0,02 - 0,03% to costprice.

(Etc. "GP Thunder H1 - 8500K - 100W 225" costs 225,- DKK, but the contribution sets the price to 230,- DKK)

 

The weird thing is, that i cannot find anywhere the contrib calculates a price, which means it has to be a conflict with the org. OSC?

 

Any ideas anybody?

Link to comment
Share on other sites

hi wex,

how do you manage the taxes? I mean, do ou display with or without tax? Do you have several taxes set?

It seems that the code add a tax to the price... Should it?

 

Thank you very much for your response.

We have two Tax's added. Both on 25%(Moms). All prices are shown including Taxes.

The Order Editor executes adding the taxes fine. To me it dosent seem possibly its the taxes. Since i adds it perfectly, plus tax is 25% - the Order Editor adds 2%.

 

You can see an example here(I blurred out the private info). The site is in danish so it might look weird.

 

As you cant see the products are identical.

The upper product is bought via the shop. The Second is added via the order editor.

 

orderajax.jpg

 

 

PS. Is a fix for the SPECIALS price found yet?

Link to comment
Share on other sites

Ledave is there anyway to edit the product name as well? I use that in order editor but could completely get rid of order editor and use ajax order editor if I could do that. Thanks in advance.

Link to comment
Share on other sites

wex:sorry, I can't look into that. Here you will find my orders_ajax (in txt mode so you can see it), the one I use in my shop: I have no problem of 2-3% as your comenting. Maybe it can help you: compare it with yours and see the diferences (if you don't have it yet, use winmerge for that).

There is some stuff relative to my shop that wont serve you. DON'T REPLACE YOUR FILE BY MINE, that would cause a lot of problems.

In this file the specials prices are managed too.

Hope it can help you, and don't hesitate to get back to me here if you need help understanding some part of the code... or for telling me that it fixed this issue :rolleyes:

 

bkpie: sure, there is always a way ;)

Get inspiration of the model.

Hope that help. As for wex, don't hesitate to ask me here about some points of coding problem you could meet.

 

cheers

have a good code, and day

Link to comment
Share on other sites

  • 2 weeks later...

Hello and before I start asking for support, I must first say that this hack does everything that I wanted it to do... Atleast on paper! :)

 

I've installed it twice now, once by uploading your core files (broke the cart beyond repair) then doing manual edits (which works, kinda) I'm now posed with this one problem...

 

screeniewm6.jpg

 

As you can see, everything that says "edited" can be, well, edited... All the other fields/totals/etc give me the dialog box saying that it was edited, refresh to see the changes but as you can see, they do not change.

 

This is also the case for adding products. The dialog comes up, the search works, it says that the product was placed into the order and to refresh, however after refresh there is no new product.

 

 

Could you please point me in the right direction? Thank you in advance!

Link to comment
Share on other sites

hi sabian,

well I'm confused... I don't understand why it's working for some stuff and not for others :huh:

let's start with the "add a product" action, it may be easier.

¿Have you check if the product is in the db, in the orders_products table, but with a wrong oID?

Also, as my files are heavy modified, could you paste here the part of the orders_ajax.php that add the product in the db? (i think it's if ($action == 'set_attributes') { and also what is like the function setAttr(tabl){ in the includes/ajax.js

 

see you.

 

ps: as the forum doesn't warn me when there is an answer, if I don't answer you in 2 days don't hesitate to send me a pm :)

Edited by ledave
Link to comment
Share on other sites

Hello Dave,

 

I'll get to this a little bit later just wanted to clarify that this was installed on a stock shopping cart as we are trying to find an alternative to our broken Zencart shop.

 

So, this was installed using untouched code base and untouched database scheme from a fresh downloaded snapshot of osC.

 

One thing I will mention here to see if it helps find the problem is this...

 

During the installed, your install document states:

In

*****************************

* - catalog/admin/orders.php*

*****************************

line 149:

FIND:

 	<td class="main"><?php echo tep_address_format($order->customer['format_id'], $order->customer, 1, '', '<br>'); ?></td>

 

REPLACE IT WITH:

<td class="main"><?php echo tep_address_format($order->customer['format_id'], $order->customer, 1, '', '<br>', 'customers_', $oID); ?></td>

 

 

That code didn't match my orders.php, instead I had:

 	<td class="main"><?php echo tep_address_format($order->customer['format_id'], $order->billing, 1, '', '<br>'); ?></td>

 

Also in same file:

line 245-246:

FIND:

	  '			<td class="dataTableContent" align="right" valign="top"><b>' . $currencies->format($order->products[$i]['final_price'], true, $order->info['currency'], $order->info['currency_value']) . '</b></td>' . "\n" .
	   '			<td class="dataTableContent" align="right" valign="top"><b>' . $currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']) . '</b></td>' . "\n" .

 

Didn't match my orders.php, the closest code was:

		  '			<td class="dataTableContent" align="right" valign="top"><b>' . $currencies->format($order->products[$i]['final_price'], true, $order->info['currency'], $order->info['currency_value']) . '</b></td>' . "\n" .
	   '			<td class="dataTableContent" align="right" valign="top"><b>' . $currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax'], true), true, $order->info['currency'], $order->info['currency_value']) . '</b></td>' . "\n" .

 

Since it was close, I replaced it anyway, but these differences seem to deal with which address to query from the database (billing as opposed to customer) and currency queries nothing to do with the product or oID's... All other instructions to your contribution matched and went fine.

 

 

Any help you can provide will literally make the difference of whether or not we move to osC! So, no pressure! :)

Link to comment
Share on other sites

well sabiam, those lines doens't seem to interfer with our problem: the first one is about the billing address and the other is about the price of the ordered product.

Have you check what I asked you before?

Link to comment
Share on other sites

  • 2 months later...

Is it possible to use this contribution in Firefox?

 

I can click the different items in orders.php, and I can type in information in the popup, and save the data.

 

The issue is that the new data isn't loaded. (I have to manually update the page)

 

Also the popup-confirmations are in some foreign language... how is this changed? - At least into english! (I believe I have followed the INSTALL.txt correctly)

 

Do you have any ideas?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...