Jump to content
Sign in to follow this  
Maryw

Ajax Order Editor

Recommended Posts

Do you have teh admin access contrib installed?

Paste your admin/includes/configure.php file, without the part of the database access.

Share this post


Link to post
Share on other sites

yes I have it install the admin access contrib.

 

the config is from my local server

 

  define('HTTP_SERVER', 'http://192.168.1.3'); // eg, http://localhost - should not be empty for productive servers
 define('HTTP_CATALOG_SERVER', 'http://192.168.1.3');
 define('HTTPS_CATALOG_SERVER', '');
 define('ENABLE_SSL_CATALOG', 'false'); // secure webserver for catalog module
 define('DIR_FS_DOCUMENT_ROOT', 'c:/www/videowelten/'); // where the pages are located on the server
 define('DIR_WS_ADMIN', '/videowelten/admin/'); // absolute path required
 define('DIR_FS_ADMIN', 'c:/www/videowelten/admin/'); // absolute pate required
 define('DIR_WS_CATALOG', '/videowelten/'); // absolute path required
 define('DIR_FS_CATALOG', 'c:/www/videowelten/'); // absolute path required
 define('DIR_WS_IMAGES', 'images/');
 define('DIR_WS_ICONS', DIR_WS_IMAGES . 'icons/');
 define('DIR_WS_CATALOG_IMAGES', DIR_WS_CATALOG . '../../images/');
 define('DIR_WS_INCLUDES', 'includes/');
 define('DIR_WS_BOXES', DIR_WS_INCLUDES . 'boxes/');
 define('DIR_WS_FUNCTIONS', DIR_WS_INCLUDES . 'functions/');
 define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/');
 define('DIR_WS_MODULES', DIR_WS_INCLUDES . 'modules/');
 define('DIR_WS_LANGUAGES', DIR_WS_INCLUDES . 'languages/');
 define('DIR_WS_CATALOG_LANGUAGES', DIR_WS_CATALOG . 'includes/languages/');
 define('DIR_FS_CATALOG_LANGUAGES', DIR_FS_CATALOG . 'includes/languages/');
 define('DIR_FS_CATALOG_IMAGES', DIR_FS_CATALOG . 'images/');
 define('DIR_FS_CATALOG_MODULES', DIR_FS_CATALOG . 'includes/modules/');
 define('DIR_FS_BACKUP', DIR_FS_ADMIN . 'backups/');

 

I have the file access able in the access config so that this can not be kill the file with the access.

Edited by bluepower2010

Share this post


Link to post
Share on other sites
yes I have it install the admin access contrib.
¿have you autorized the new files in the admin access panel?

Share this post


Link to post
Share on other sites

/orders.php?page=1&oID=10&action=edit

 

this url code would be the error. Because it is not up to date after I have clickt on the ok button.

 

yes I have autorized the file in dem admin access panel

Edited by bluepower2010

Share this post


Link to post
Share on other sites

No. At the moment I Merge the Contrib from you with the other files from your versions of this contrib. Because I think that can be a error in one file from your contrib.

Share this post


Link to post
Share on other sites

Hi I have found the problem.

 

You must say require and not include than it will be do what it should.

 

chance this

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

 

to this:

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

 

I don't can say why.

Share this post


Link to post
Share on other sites

well that's good news! :)

I'll make the change in next version. I guess is because of the version of php.

Glad you made it.

See you.

Share this post


Link to post
Share on other sites

Can you say me, why I prices without tax after chancethe number of products what the customers will be.

 

Example:

 

Bevor the price will be 94 euro by 2 quanty after I had chance it on one and then back to two the price will not be 94. The price is there 80.54 Euro. I don't find anything wich the wrong price will be come. But I thing that in the order_ajax the price will be not added with tax.

Share this post


Link to post
Share on other sites

hi bluepower2010,

Thanks for being my beta tester :)

I'm actually working in improving the tax part of this contrib. But if you do not use diferents tax rates, it should work properly.

I don't really understand what you describe of the problem. I think the best thing to do is waiting for the next version of my contrib (I'm hoping having it ready tomorrow or the day after).

I'll let you know when it's ready.

Share this post


Link to post
Share on other sites

Your contrib works now perfectly.

 

It considers tax immediately and counting it also correctly.

Only by the tax of the shipping modul forgets the contrib the tax count. That should be comes with the last version bevor it can be use perfectly and correctly in a live shop system.

 

I hope you can me my bad English forgive.

Share this post


Link to post
Share on other sites

hi bluepower,

the thing with the tax of the shipping and others orders_totals is a level more trickier :'(

I cannot imagine a way to make it in a global way, for every single OSC user.

I've worked the code of the orders_ajax.php to make it funcional in my store: I apply 16% of VAT at every orders_total field. Maybe you can do the same wih yours, with your country's tax rate.

Here is my code:

<?php
 //header('Content-type: text/html; charset=ISO-8859-1');
 require('includes/application_top.php');

 require(DIR_WS_CLASSES . 'currencies.php');
 $currencies = new currencies();

 function tep_db_update_totals($order_id) {
  //we have to update the orders_total table
  $products_total_query = tep_db_query("select final_price, products_quantity, products_tax from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . $order_id . "'");
  $price = 0;
  $total = 0;
  $taxes = array();
  if (tep_db_num_rows($products_total_query)) {
	  while ($products_total = tep_db_fetch_array($products_total_query)) {
		  $iva = round((100 + (float)$products_total['products_tax']) / 100, 4);
		  $price += (float)round(((float)$products_total['final_price'] * (int)$products_total['products_quantity']) * $iva, 2);
		  //fill the array of taxes to know which tax is used.
		  if (tep_not_null($products_total['products_tax'])) {
			  $tax_description_query = tep_db_query("select tax_description from " . TABLE_TAX_RATES . " where tax_rate = '" . $products_total['products_tax'] . "'");
			  $tax_description = tep_db_fetch_array($tax_description_query);

			  if (sizeof($taxes)) {
				  $ya_esta = false;
				  for ($i=0; $i<sizeof($taxes); $i++) {
					  if (in_array($tax_description['tax_description'] . ':', $taxes[$i])) {
						  $ya_esta = $i;
					  }
				  }
				  if ($ya_esta === false) {
					  $taxes[] = array('description' => $tax_description['tax_description'] . ':', 'value' => round(((((float)$products_total['final_price'] * (int)$products_total['products_quantity']) * (float)$products_total['products_tax']) / 100), 4));
				  } else {
					  $taxes[$ya_esta]['value'] += round(((((float)$products_total['final_price'] * (int)$products_total['products_quantity']) * (float)$products_total['products_tax']) / 100), 4);
				  }
			  } else {
				  $taxes[] = array('description' => $tax_description['tax_description'] . ':', 'value' => round(((((float)$products_total['final_price'] * (int)$products_total['products_quantity']) * (float)$products_total['products_tax']) / 100), 4));
			  }
		  }
	  }
  }

  $orders_total_query = tep_db_query("select * from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . $order_id . "' and class != 'ot_tax' order by sort_order");//first anything but the tax (this part is trickier, let's do it appart)
  while ($order_total = tep_db_fetch_array($orders_total_query)) {
	  if ($order_total['class'] == 'ot_subtotal') {
		  if (!tep_not_null($order_total['value'])) {//because of create_order problem
			  $old_value_txt = '0.00EUR';
		  } else {
			  $old_value_txt = round((float)$order_total['value'], 2);
		  }
		  $new_value = (float)$price;
		  $new_text = str_replace($old_value_txt, round($new_value, 2), $order_total['text']);
		  tep_db_query("update " . TABLE_ORDERS_TOTAL . " set text = '" . $new_text . "', value = '" . $new_value . "' where orders_total_id = '" . $order_total['orders_total_id'] . "' and class = 'ot_subtotal'");
		  $total += (float)$new_value;
	  } elseif ($order_total['class'] == 'ot_total') {
		  if ($order_total['value'] == '0.0000') {//because of create_order problem
			  $old_value_txt = '0.00EUR';
		  } else {
			  $old_value_txt = round((float)$order_total['value'], 2);
		  }
		  $new_value = (float)$total;
		  $new_text = str_replace($old_value_txt, round($new_value, 2), $order_total['text']);
		  tep_db_query("update " . TABLE_ORDERS_TOTAL . " set text = '" . $new_text . "', value = '" . $new_value . "' where orders_total_id = '" . $order_total['orders_total_id'] . "' and class = 'ot_total'");
	  } else {
		  $total += round((float)$order_total['value'], 4);
		  $ht = round(((float)$order_total['value']/1.16), 4);
		  $tva = (float)$order_total['value']-(float)$ht;
		  if (sizeof($taxes)) {
			  $ya_esta = false;
			  for ($i=0; $i<sizeof($taxes); $i++) {
				  if (in_array('IVA 16%:', $taxes[$i])) {
					  $ya_esta = $i;
				  }
			  }
			  if ($ya_esta === false) {
				  $taxes[] = array('description' => 'IVA 16%:', 'value' => $tva);
			  } else {
				  $taxes[$ya_esta]['value'] += (float)$tva;
			  }
		  } else {
			  $taxes[] = array('description' => 'IVA 16%:', 'value' => $tva);
		  }
	  }
  }
  //the taxes
  if (sizeof($taxes)) {
	  $orders_total_tax_query = tep_db_query("select * from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . $order_id . "' and class = 'ot_tax'");
	  //update the ot_tax with the same title
	  //if title doesn't exist, insert it
	  $tax_updated = array();
	  while ($orders_total_tax = tep_db_fetch_array($orders_total_tax_query)) {
		  $eliminate_tax = true;
		  for ($i=0; $i<sizeof($taxes); $i++) {
			  if (in_array($orders_total_tax['title'], $taxes[$i])) {
				  $eliminate_tax = false;
				  //keep in variable that this tax is done
				  $tax_updated[] = $orders_total_tax['title'];
					//first check if the ot_tax with that title already exists, otherwise, create it
				  $old_value_txt = round((float)$orders_total_tax['value'], 2);
				  $new_value = $taxes[$i]['value'];
				  $new_value_txt = round((float)$new_value, 2);
				  $new_text = str_replace($old_value_txt, (string)$new_value_txt, $orders_total_tax['text']);
				  tep_db_query("update " . TABLE_ORDERS_TOTAL . " set text = '" . $new_text . "', value = '" . $new_value . "' where orders_total_id = '" . $orders_total_tax['orders_total_id'] . "' and class = 'ot_tax'");
			  }
		  }
		  if ($eliminate_tax == true) {//we have eliminate the last product of one tax_rate->eliminate the ot_field
			  tep_db_query("delete from " . TABLE_ORDERS_TOTAL . " where orders_total_id = '" . $orders_total_tax['orders_total_id'] . "' limit 1");
		  }
	  }
	  //insert a new tax rate in the orders_total table, if all of taxes[] is not in $tax_updated[]
	  for ($i=0; $i<sizeof($taxes); $i++) {
		  if ((!in_array($taxes[$i]['description'], $tax_updated)) && ((float)$taxes[$i]['value'] > 0)) {
			  //get the order's currency
			  $currency_query = tep_db_query("select currency from " . TABLE_ORDERS . " where orders_id = '" . $order_id . "'");
			  $currency = tep_db_fetch_array($currency_query);
			  //prepare text (value with currency)
			  $texto = round((float)$taxes[$i]['value'], 2);
			  $texto = (string)$texto . $currency['currency'];
			  tep_db_query("insert into " . TABLE_ORDERS_TOTAL . " (orders_id, title, text, value, class, sort_order) values ('" . $order_id . "', '" . $taxes[$i]['description'] . "', '" . $texto . "', '" . $taxes[$i]['value'] . "', 'ot_tax', '3')");
		  }
	  }
  }
 }
 tep_db_update_totals('EO1221054');
 $action = $HTTP_GET_VARS['action'];
 if (($action == 'eliminate') || ($action == 'update_product')) {//eliminate or modify product
  if ($action == 'eliminate') {
	  tep_db_query("delete from " . TABLE_ORDERS_PRODUCTS . " where orders_products_id = '" . $HTTP_GET_VARS['pID'] . "' limit 1");
	  $attributes_query = tep_db_query("select orders_products_attributes_id from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_products_id = '" . $HTTP_GET_VARS['pID'] . "'");
	  if (tep_db_num_rows($attributes_query)) {//if the products has attributes, eliminate them
		  while ($attributes = tep_db_fetch_array($attributes_query)) {
			  tep_db_query("delete from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_products_attributes_id = '" . $attributes['orders_products_attributes_id'] . "' limit 1");
		  }
	  }
  } else {
	  //get the price to change order totals
	  //but first, change it if we change price of attributes (so we get directly the good final_price)
	  $field = $HTTP_GET_VARS['field'];
	  if ($field == 'options') {
		  tep_db_query("update " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " set products_options_values = '" . $HTTP_GET_VARS['new_value'] . "',  options_values_price = '" . round((float)$HTTP_GET_VARS['option_price'], 4) . "' where orders_products_id = '" . $HTTP_GET_VARS['pID'] . "' and products_options = '" . $HTTP_GET_VARS['extra'] . "'");
		  tep_db_query("update " . TABLE_ORDERS_PRODUCTS . " set final_price = (products_price + '" . round((float)$HTTP_GET_VARS['option_price'], 4) . "') where orders_products_id = '" . $HTTP_GET_VARS['pID'] . "'");
	  } elseif (stristr($field, 'price')) {
		  $adapt_price_query = tep_db_query("select options_values_price from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_products_id = '" . $HTTP_GET_VARS['pID'] . "' and options_values_price != 0");
		  if (tep_db_num_rows($adapt_price_query)) {
			  $adapt_price = tep_db_fetch_array($adapt_price_query);
			  $option_price = (float)$adapt_price['options_values_price'];
		  } else {
			  $option_price = 0;
		  }
		  if (stristr($field, '_excl')) {
			  $new_price = round((float)$HTTP_GET_VARS['new_value'], 4);
		  } else {
			  $tax_query = tep_db_query("select products_tax from " . TABLE_ORDERS_PRODUCTS . " where orders_products_id = '" . $HTTP_GET_VARS['pID'] . "' and products_tax != 0");
			  if (tep_db_num_rows($tax_query)) {
				  $tax_ = tep_db_fetch_array($tax_query);
				  $percent = (float)$tax_['products_tax'];
				  $percent = round(($percent/100), 4);
				  $percent = $percent + 1;
				  $new_price = round(round((float)$HTTP_GET_VARS['new_value']/$percent, 4), 4);
			  } else {
				  $new_price = round((float)$HTTP_GET_VARS['new_value'], 4);
			  }
		  }
		  tep_db_query("update " . TABLE_ORDERS_PRODUCTS . " set final_price = '" . $new_price . "', products_price = '" . ($new_price - $option_price) . "' where orders_products_id = '" . $HTTP_GET_VARS['pID'] . "'");
	  } else {
		  tep_db_query("update " . TABLE_ORDERS_PRODUCTS . " set " . $field . " = '" . tep_db_prepare_input($HTTP_GET_VARS['new_value']) . "' where orders_products_id = '" . $HTTP_GET_VARS['pID'] . "'");
	  }
  }
  //we have to update the orders_total table
  tep_db_update_totals($HTTP_GET_VARS['order']);

  //that's it, tell the administrator
  //ENGLISH
  //echo (($action == 'eliminate') ? 'Product eliminated.' : 'Order updated.' ) . "\n" . 'Refresh the browser to see the changes.';
  //FRANÇAIS
  //echo (($action == 'eliminate') ? 'Produit eliminé.' : 'Commande actualisée.' ) . "\n" . 'Rafraichir le navigateur pour voir les changements.';
  //ESPAÑOL
  echo (($action == 'eliminate') ? 'Producto eliminado.' : 'Pedido actualizado.' ) . "\n" . 'Refrescar el navegador para ver los cambios.';
 } elseif ($action == 'update_order_field') {
  tep_db_query("update " . $HTTP_GET_VARS['db_table'] . " set " . $HTTP_GET_VARS['field'] . " = '" . tep_db_prepare_input($HTTP_GET_VARS['new_value']) . "' where orders_id = '" . $HTTP_GET_VARS['oID'] . "'");
  //that's it, tell the administrator
  //ENGLISH
  //echo 'Field updated.' . "\n" . 'Refresh the browser to see the changes.';
  //FRANÇAIS
  //echo 'Donnée actualisée.' . "\n" . 'Rafraichir le navigateur pour voir les changements.';
  //ESPAÑOL
  echo 'Pedido actualizado.' . "\n" . 'Refrescar el navegador para ver los cambios.';
 } elseif ($action == 'search') {//search products in the db.
  $products_query = tep_db_query("select distinct p.products_id, pd.products_name, p.products_model from " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . TABLE_PRODUCTS . " p on (p.products_id = pd.products_id) where (pd.products_name like '%" . tep_db_input($HTTP_GET_VARS['keyword']) . "%' or  p.products_model like '%" . tep_db_input($HTTP_GET_VARS['keyword']) . "%') and  pd.language_id = '" . $languages_id . "' and p.products_status = '1' order  by pd.products_name asc limit 20");
  if (tep_db_num_rows($products_query)) {
	  while ($products = tep_db_fetch_array($products_query)) {
		  $results[] = '<a href="java script:selectProduct(\'' .  $products['products_id'] . '\', \'' .  addslashes(tep_output_string_protected($products['products_name'])) . '\');">' .  $products['products_name'] . (($products['products_model'] != '') ? ' (' . $products['products_model'] . ')' : '') . '</a>' . "\n";
	  }
  } else {
	  $results[] = PRODUCTS_SEARCH_NO_RESULTS;
  }
  echo implode('<br>' . "\n", $results);
 } elseif ($action == 'attributes') {
  //we create an AJAX form
  $attributes = '<form name="attributes" id="attributes" action="" onsubmit="setAttr(); return false"><input type="hidden" name="products_id" value="' . (int)$HTTP_GET_VARS['prID'] . '">';
  //this part comes integraly from OSC catalog/product_info.php
  $products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['prID'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'");
  $products_attributes = tep_db_fetch_array($products_attributes_query);
  if ($products_attributes['total'] > 0) {
	  $attributes .= '<table border="0" cellspacing="0" cellpadding="2" class="dataTableRow" width="100%"><tr><td class="dataTableContent" colspan="2">' . TEXT_PRODUCT_OPTIONS . '</td>			</tr>';
	  $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['prID'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' order by popt.products_options_name");
	  while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
		  $products_options_array = array();
		  $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 " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['prID'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$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['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->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
			  }
		  }
		  $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>';
	  }
	  $attributes .= '<tr><td colspan="2">' . tep_image_submit('button_confirm.gif', IMAGE_CONFIRM) . '</td></tr></table></form>';
  } else {
	  $attributes .= tep_image_submit('button_confirm.gif', IMAGE_CONFIRM) . '</form>';
  }
  echo $attributes;
 } elseif ($action == 'set_attributes') {
  $attributes = array();
  $products_id = 0;
  $products_quantity = 0;
  foreach($HTTP_POST_VARS as $key => $value) {
	  if ($key == 'products_id') {
		  $products_id = $value;
	  } elseif ($key == 'products_quantity') {
		  $products_quantity = $value;
	  } elseif (stristr($key, 'trid_')) {
		  $attributes[] = array(substr($key, 6), $value);
	  }
  }
  $orders_id = $HTTP_GET_VARS['oID'];
  //select customer's group
  $b2b_query = tep_db_query("select c.customers_group_id from " . TABLE_CUSTOMERS . " c, " . TABLE_ORDERS . " o where o.orders_id = '" . $orders_id . "' and o.customers_id = c.customers_id");
  $b2b = tep_db_fetch_array($b2b_query);
  //check for special price
  $special_price_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . $products_id . "' and (expires_date > now() or expires_date = NULL or expires_date = '0000-00-00 00:00:00') and status = '1' and customers_group_id = '" . $b2b['customers_group_id'] . "'");
  if (tep_db_num_rows($special_price_query)) {
	  $special_price = tep_db_fetch_array($special_price_query);
	  $product_price = $special_price['specials_new_products_price'];
  } else {
	  if ($b2b['customers_group_id'] != 0) {
		  $product_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . $products_id . "' and customers_group_id = '" . $b2b['customers_group_id'] . "'");
		  $product_price_ = tep_db_fetch_array($product_price_query);
		  $product_price = $product_price_['customers_group_price'];
	  } else {
		  $product_price_query = tep_db_query("select products_price from " . TABLE_PRODUCTS . " where products_id = '" . $products_id . "'");
		  $product_price_ = tep_db_fetch_array($product_price_query);
		  $product_price = $product_price_['products_price'];
	  }
  }
  $product_info_query = tep_db_query("select p.products_model, pd.products_name, p.products_tax_class_id from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id where p.products_id = '" . $products_id . "' and pd.language_id = '" . (int)$languages_id . "'");
  $product_info = tep_db_fetch_array($product_info_query);
  if (DISPLAY_PRICE_WITH_TAX == 'true') {
	  $tax_query = tep_db_query("select tax_rate, tax_description from " . TABLE_TAX_RATES . " where tax_rates_id = '" . $product_info['products_tax_class_id'] . "'");
	  $tax_ = tep_db_fetch_array($tax_query);
	  $tax = $tax_['tax_rate'];
	  $tax_desc = $tax_['tax_description'];
  } else {
	  $tax = 0;
  }
  //OJO, hay que insertar primero el product para saber el orders_products_id...
  $attribute_price_sum = 0;
  $attribute_update = false;
  if (sizeof($attributes) > 0) {
	  $attribute_update = true;
	  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_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_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_update_totals($orders_id);
  //that's it, tell the administrator
  //ENGLISH
  //echo 'Product added.' . "\n" . 'Refresh the browser to see the changes.';
  //FRANÇAIS
  //echo 'Article ajouté.' . "\n" . 'Rafraichir le navigateur pour voir les changements.';
  //ESPAÑOL
  echo 'Producto insertado.' . "\n" . 'F5 para ver los cambios.';
 } elseif ($action == 'orders_total_update') {
  if ($HTTP_GET_VARS['column'] == 'value') {
	  $text_query = tep_db_query("select text, value from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . $HTTP_GET_VARS['oID'] . "' and class = '" . $HTTP_GET_VARS['class'] . "'");
	  $text_ = tep_db_fetch_array($text_query);
	  $text = str_replace(round((float)$text_['value'], 2), round((float)$HTTP_GET_VARS['new_value'] , 2), $text_['text']);
	  tep_db_query("update " . TABLE_ORDERS_TOTAL . " set text = '" . $text . "' where orders_id = '" . $HTTP_GET_VARS['oID'] . "' and class = '" . $HTTP_GET_VARS['class'] . "'");
  }
  tep_db_query("update " . TABLE_ORDERS_TOTAL . " set " . $HTTP_GET_VARS['column'] . " = '" . $HTTP_GET_VARS['new_value'] . "' where orders_id = '" . $HTTP_GET_VARS['oID'] . "' and class = '" . $HTTP_GET_VARS['class'] . "'");
  tep_db_update_totals($HTTP_GET_VARS['oID']);
  //that's it, tell the administrator
  //ENGLISH
  //echo 'Total updated.' . "\n" . 'Refresh the browser to see the changes.';
  //FRANÇAIS
  //echo 'Total actualisé.' . "\n" . 'Rafraichir le navigateur pour voir les changements.';
  //ESPAÑOL
  echo 'Total actualizado.' . "\n" . 'F5 para ver los cambios.';
 } elseif ($action == 'new_order_total') {
  $sort_order_query = tep_db_query("select max(sort_order) as maxim from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . $HTTP_GET_VARS['oID'] . "' and class != 'ot_total'");
  $sort_order = tep_db_fetch_array($sort_order_query);
  $new_sort_order = (int)$sort_order['maxim'] + 1;

  //get the order's currency
  $currency_query = tep_db_query("select currency from " . TABLE_ORDERS . " where orders_id = '" . $order_id . "'");
  $currency = tep_db_fetch_array($currency_query);

  $class_query = tep_db_query("select class from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . $HTTP_GET_VARS['oID'] . "' and class like '%ot_extra_%'");
  $classs = 'ot_extra_' . (tep_db_num_rows($class_query) + 1);

  tep_db_query("insert into " . TABLE_ORDERS_TOTAL . " (orders_id, title, text, value, class, sort_order) values ('" . $HTTP_GET_VARS['oID'] . "', '" . $HTTP_GET_VARS['title'] . ":', '" . round((float)$HTTP_GET_VARS['value'], 2) . $currency['currency'] . "', '" . round((float)$HTTP_GET_VARS['value'], 4) . "', '" . $classs . "', '" . $new_sort_order . "')");
  tep_db_update_totals($HTTP_GET_VARS['oID']);
  //that's it, tell the administrator
  //ENGLISH
  //echo 'Total updated.' . "\n" . 'Refresh the browser to see the changes.';
  //FRANÇAIS
  //echo 'Total actualisé.' . "\n" . 'Rafraichir le navigateur pour voir les changements.';
  //ESPAÑOL
  echo 'Total actualizado.' . "\n" . 'F5 para ver los cambios.';
 }
?>

You should just replace the 1.16 by your tax rate. Tell me if I can do anything else.

good luck and good code

Share this post


Link to post
Share on other sites

Hi ledave,

 

I downloaded your new version from MArch 30 and it works great for me, it shows up now. I also watched your youtube movie, good idea! I am sorry I did not get back to you weeks ago when I had problems, I had to leave it and work on other projects until today. I think my problem too was php 5.

 

I have problems with tax on shipping yet, I have to do other things before I can fix it or figure it out so I will come back later. It also asks me value for euro? Can I remove this part somewhere, I am in Canada and for this shop only ship in Canada so don't need to know euros. One note, in the install file you say can comment out spanish lines and uncomment english, this needs to be done in orders_ajax.php too or still spanish instructions show after edits.

 

This is much easier install than order editor (I use it on a different shop last year) and did not conflict with any other mods I have done, and I have done over 30 to this shop! Thank you for spending your time on a contrib to benefit us all.

Share this post


Link to post
Share on other sites

hi gardenho,

 

firstavail, if you're a french-speaking canadian, we could speak in the french forum: http://www.oscommerce-fr.info/forum/index....showtopic=44245 (I'm a french-speaking belgian myself, so it would be easier for both).

About the euro problem, I've tried to make that contrib currencies friendly. When exactly does it ask you for value in euros? ...okay, wait a minute: it's when creating a new order_total field, right? You should just edit the phrase on line 99:

var newValue = prompt("Valor en euros:", "0.0000");

to something like that

var newValue = prompt("Amount in canadian dolar:", "0.0000");

and that should do the trick. The value is inserted in the database without the currency, it will be you're shop's default currency.

 

About the spanish instructions, it's mainly in the admin/orders_ajax.php that you have to comment then and uncoment the english ones. But there is some in the admin/includes/ajax.js. For example, on line 127:

alert('Producto añadido' + "\n" + 'F5 para ver los cambios.');

that you should edit to:

alert(Product added.' + "\n" + 'Refresh the browser to see the changes.');

And to change the rest of the text in spanish, llok in the ajax.js file for the lines that have prompt, and change the texts between " (<- sorry, I don't know what's the name of that sign :blush: )

 

Glad you like and use it, and it's my pleasure to give a little something to that comunity that gave me so much, something to eat everyday, for example :thumbsup:

Share this post


Link to post
Share on other sites

Hi,

 

I just installed the latest version of this contrib - but it has a problem in admin>includes>functions>general.php in the tep_address_format module.

 

It's just a parse error on this 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>' : '');

 

Is anyone else experiencing this problem?

 

Rob

Share this post


Link to post
Share on other sites

hi Rob,

this line is correct. Maybe the line before or after.

Anyway, the best way to install a contrib is merge the files with a compare and merge program (I use winmerge, free and free): with this tool you can see the difference between 2 files and avoid those parse errors.

good luck

Share this post


Link to post
Share on other sites

Hi!

 

I have a problem with the product prices. After installed the contrib, the price for each produkt is multipilicated with 10!

Before install it was 5 €, after it is 50 €.

The totals are correct if I don't change anything in the order. If I change something, they are also multiplicated with 10.

What can I do?

 

 

Greetings

Nika

Share this post


Link to post
Share on other sites

hi Nika,

well I don't understand, that's weird.

¿have you changed anything in the orders_ajax.php file?

When you installed it, ¿everything went smooth or do you had problems?

Share this post


Link to post
Share on other sites

Hi There,

i'm testing the Ajax Order Editor, it's simply great but i found out a "bug" which may affect the editing of order.

The price of added products are always FULL prices...if some products is on special it will be added as a full price, not special price.

Looking at the way the "order editor" contribution (the non ajax one) handles this is with this portion of code, and i tried to mod to make it work:

			$special_price = tep_db_query("
		SELECT specials_new_products_price 
		FROM " . TABLE_SPECIALS . " 
		WHERE products_id = " . (int)$HTTP_GET_VARS['prID'] . "
		");
		$offer = tep_db_fetch_array($special_price);
		if ($offer <= $product_info['products_price']) {
		$product_info['products_price'] = $offer ; 
 			} 

But it keeps adding prod with 0 price...

Any help Dave? :)

Thx

Fab


Advice on forum are Free, Email or Pm to fix your site is work...which I charge for :)

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

Share this post


Link to post
Share on other sites

hi freeman,

yep, that's right, one small bug. I tought I had corrected but it seems not...

Here what I have in the brackets of } elseif ($action == 'set_attributes') {

 

		 $orders_id = $HTTP_GET_VARS['oID'];
	  $attributes = array();
	  $products_id = 0;
	  $products_quantity = 0;
	  foreach($HTTP_POST_VARS as $key => $value) {
		  if ($key == 'products_id') {
			  $products_id = $value;
		  } elseif ($key == 'products_quantity') {
			  $products_quantity = $value;
		  } elseif (stristr($key, 'trid_')) {
			  $attributes[] = array(substr($key, 6), $value);
		  }
	  }
	  //select customer's group
	  $b2b_query = tep_db_query("select c.customers_group_id from " . TABLE_CUSTOMERS . " c, " . TABLE_ORDERS . " o where o.orders_id = '" . $orders_id . "' and o.customers_id = c.customers_id");
	  $b2b = tep_db_fetch_array($b2b_query);
	  //check for special price
	  $special_price_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . $products_id . "' and status = '1' and customers_group_id = '" . $b2b['customers_group_id'] . "'");
	  if (tep_db_num_rows($special_price_query)) {
		  $special_price = tep_db_fetch_array($special_price_query);
		  $product_price = $special_price['specials_new_products_price'];
	  } else {
		  if ($b2b['customers_group_id'] != 0) {
			  $product_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . $products_id . "' and customers_group_id = '" . $b2b['customers_group_id'] . "'");
			  $product_price_ = tep_db_fetch_array($product_price_query);
			  $product_price = $product_price_['customers_group_price'];
		  } else {
			  $product_price_query = tep_db_query("select products_price from " . TABLE_PRODUCTS . " where products_id = '" . $products_id . "'");
			  $product_price_ = tep_db_fetch_array($product_price_query);
			  $product_price = $product_price_['products_price'];
		  }
	  }
	  $product_info_query = tep_db_query("select p.products_model, pd.products_name, p.products_tax_class_id from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id where p.products_id = '" . $products_id . "' and pd.language_id = '" . (int)$languages_id . "'");
	  $product_info = tep_db_fetch_array($product_info_query);
	  if (DISPLAY_PRICE_WITH_TAX == 'true') {
		  $tax_query = tep_db_query("select tax_rate, tax_description from " . TABLE_TAX_RATES . " where tax_rates_id = '" . $product_info['products_tax_class_id'] . "'");
		  $tax_ = tep_db_fetch_array($tax_query);
		  $tax = $tax_['tax_rate'];
		  $tax_desc = $tax_['tax_description'];
	  } else {
		  $tax = 0;
	  }
	  //OJO, hay que insertar primero el product para saber el orders_products_id...
	  $attribute_price_sum = 0;
	  $attribute_update = false;
	  if (sizeof($attributes) > 0) {
		  $attribute_update = true;
		  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_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_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'");
	  }

as you can see, besides the specials price, it checks the customer's group (SPPC contrib).

If you don't have it installed in youir store, you should erase this:

		  //select customer's group
	  $b2b_query = tep_db_query("select c.customers_group_id from " . TABLE_CUSTOMERS . " c, " . TABLE_ORDERS . " o where o.orders_id = '" . $orders_id . "' and o.customers_id = c.customers_id");
	  $b2b = tep_db_fetch_array($b2b_query);

and this

			  if ($b2b['customers_group_id'] != 0) {
			  $product_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . $products_id . "' and customers_group_id = '" . $b2b['customers_group_id'] . "'");
			  $product_price_ = tep_db_fetch_array($product_price_query);
			  $product_price = $product_price_['customers_group_price'];
		  } else {

(and don't forget the last closing bracket.

cheers

Share this post


Link to post
Share on other sites

thanks...but looks like products aren't added :(

Can you post the fixed file and update the contribution ? Maybe i'm missing something :|


Advice on forum are Free, Email or Pm to fix your site is work...which I charge for :)

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

Share this post


Link to post
Share on other sites

hi craxx,

I'm sorry to say that no, it isn't includes QTpro.

I do have it installed in my shop, but I update the stock when I change the order's status to send, so I only do the update once, in the moment the products really leave the store.

 

Freeman, I'm preparing a 2.0 version of that contrib: besides the fact that 2.0 is cool right now :lol: , I've thought a way to do it in a more eficient way.

I'll keep you updated.

 

cu

Edited by ledave

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  

×