ka0osk Posted March 25, 2005 Share Posted March 25, 2005 I just installed this contrib and now I get: Fatal error: Cannot redeclare tep_db_connect() (previously declared in /hshpere/local/home/ka0osk/midwesttent.com/admin/includes/functions/database.php:13) in /hshpere/local/home/ka0osk/midwesttent.com/admin/includes/functions/database.php on line 13 Wherever I hit edit.... Anyone got any ideas? KA0OSK :( Quote Link to comment Share on other sites More sharing options...
ka0osk Posted March 26, 2005 Share Posted March 26, 2005 I just installed this contrib and now I get: Fatal error: Cannot redeclare tep_db_connect() (previously declared in /hshpere/local/home/ka0osk/midwesttent.com/admin/includes/functions/database.php:13) in /hshpere/local/home/ka0osk/midwesttent.com/admin/includes/functions/database.php on line 13 Wherever I hit edit.... Anyone got any ideas? KA0OSK :( <{POST_SNAPBACK}> I am replying to my own stuff again... seems something happens to files when I download then upload them, even if I dont change them...maybe I am not doing it in the right mode? Let me know if you figger out my goomba! I managed to corrupt my backup.php quite nicely...DOH! Quote Link to comment Share on other sites More sharing options...
henningl Posted March 29, 2005 Share Posted March 29, 2005 I'm hoping maybe someone can help. For some reason when I try to add a product, I select the first catagory, it works, then the 2nd, it works. But when I get to the third catagory to select(or if there are no more catagories and I have to select a product) it is blank and there is nothing to select. Also if I try to select a first catagory with only products in it and no other catagories. The attributes of the product will show up blank. I hope this makes sence. Anyone have any idea's what is wrong? Thanks -Dustin <{POST_SNAPBACK}> Hi, I had the same problem and found out that this contrib doesn't work well on servers with register_globals turned off in php.ini . In old versions of php register_globals was turned on by default, but this has been changed because of security issues. Adding the following to the top of edit_orders.php (AFTER "<?" ) should resolve the issue, allthough a complete rewrite of the mod would be best. if (!empty($_GET)) { extract($_GET); } else if (!empty($HTTP_GET_VARS)) { extract($HTTP_GET_VARS); } if (!empty($_POST)) { extract($_POST); } else if (!empty($HTTP_POST_VARS)) { extract($HTTP_POST_VARS); } Quote Link to comment Share on other sites More sharing options...
canajun Posted March 29, 2005 Share Posted March 29, 2005 Still having problems of the final total being doubled whenever I hit the 'update' button.. doesn't matter what I change in the order.... Anybody have a solution to this problem? Thanks! Quote Link to comment Share on other sites More sharing options...
Guest Posted March 31, 2005 Share Posted March 31, 2005 Hey, this contrib is working fine, but i find one bug: after editing order i activate the option notify customer and click update. all seems to be ok, but the customer receive no email ---- why? I can't find the mistake, please help! Here is the edit_orders.php in admin: <?php /* $Id: edit_orders.php,v 1.21 2004/09/18 15:46:00 jrb Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2003 osCommerce Released under the GNU General Public License Written by Jonathan Hilgeman of SiteCreative.com ([email protected]) - Updated By Jesse Ryan Barrick & Christian Binkert Version History --------------------------------------------------------------- 04/01/05 1.60 - Huge list of changes ;-) 18/09/04 1.58 - Changed Order Edit page to show full Credit Card Number 16/07/04 1.56 - Added a check for missing ot_subtotal on update 08/08/03 1.2a - Fixed a query problem on osC 2.1 stores. 08/08/03 1.2 - Added more recommendations to the instructions. Added "Customer" fields for editing on osC 2.2. Corrected "Billing" fields so they update correctly. Added Company and Suburb Fields. Added optional shipping tax variable. First (and hopefully last) fix for currency formatting. 08/08/03 1.1 - Added status editing (fixed order status bug from 1.0). Added comments editing. (with compatibility for osC 2.1) Added customer notifications. Added some additional information to the instructions file. Fixed bug with product names containing single quotes. 08/07/03 1.0 - Original Release. To Do in Version 1.3 --------------------------------------------------------------- Note from the author --------------------------------------------------------------- This tool was designed and tested on osC 2.2 Milestone 2.2, but may work for other versions, as well. Most database changes were minor, so getting it to work on other versions may just need some tweaking. Hope this helps make your life easier! - Jonathan Hilgeman, August 7th, 2003 */ require('includes/application_top.php'); require(DIR_WS_CLASSES . 'currencies.php'); $currencies = new currencies(); include(DIR_WS_CLASSES . 'order.php'); // START CONFIGURATION ################################ // Optional Tax Rates, e.g. shipping tax of 17.5% is "17.5" $AddCustomTax = "20.0"; // class "ot_custom", used for all unknown total modules $AddShippingTax = "20.0"; // class "ot_shippping" $AddLevelDiscountTax = "7.6"; // class "ot_lev_discount" $AddCustomerDiscountTax = "7.6"; // class "ot_customer_discount" // END OF CONFIGURATION ################################ // New "Status History" table has different format. $OldNewStatusValues = (tep_field_exists(TABLE_ORDERS_STATUS_HISTORY, "old_value") && tep_field_exists(TABLE_ORDERS_STATUS_HISTORY, "new_value")); $CommentsWithStatus = tep_field_exists(TABLE_ORDERS_STATUS_HISTORY, "comments"); $SeparateBillingFields = tep_field_exists(TABLE_ORDERS, "billing_name"); $orders_statuses = array(); $orders_status_array = array(); $orders_status_query = tep_db_query("select orders_status_id, orders_status_name from " . TABLE_ORDERS_STATUS . " where language_id = '" . (int)$languages_id . "'"); while ($orders_status = tep_db_fetch_array($orders_status_query)) { $orders_statuses[] = array('id' => $orders_status['orders_status_id'], 'text' => $orders_status['orders_status_name']); $orders_status_array[$orders_status['orders_status_id']] = $orders_status['orders_status_name']; } $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : 'edit'); // Update Inventory Quantity $order_query = tep_db_query("select products_id, products_quantity from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$oID . "'"); if (tep_not_null($action)) { switch ($action) { // 1. UPDATE ORDER ################################################################################ ############### case 'update_order': $oID = tep_db_prepare_input($HTTP_GET_VARS['oID']); $order = new order($oID); $status = tep_db_prepare_input($HTTP_POST_VARS['status']); // 1.1 UPDATE ORDER INFO ##### $UpdateOrders = "update " . TABLE_ORDERS . " set customers_name = '" . tep_db_input(stripslashes($update_customer_name)) . "', customers_company = '" . tep_db_input(stripslashes($update_customer_company)) . "', customers_street_address = '" . tep_db_input(stripslashes($update_customer_street_address)) . "', customers_suburb = '" . tep_db_input(stripslashes($update_customer_suburb)) . "', customers_city = '" . tep_db_input(stripslashes($update_customer_city)) . "', customers_state = '" . tep_db_input(stripslashes($update_customer_state)) . "', customers_postcode = '" . tep_db_input($update_customer_postcode) . "', customers_country = '" . tep_db_input(stripslashes($update_customer_country)) . "', customers_telephone = '" . tep_db_input($update_customer_telephone) . "', customers_email_address = '" . tep_db_input($update_customer_email_address) . "',"; if($SeparateBillingFields) { // Original: all database fields point to $update_billing_xxx, now they are updated with the same values as the customer fields $UpdateOrders .= "billing_name = '" . tep_db_input(stripslashes($update_customer_name)) . "', billing_company = '" . tep_db_input(stripslashes($update_customer_company)) . "', billing_street_address = '" . tep_db_input(stripslashes($update_customer_street_address)) . "', billing_suburb = '" . tep_db_input(stripslashes($update_customer_suburb)) . "', billing_city = '" . tep_db_input(stripslashes($update_customer_city)) . "', billing_state = '" . tep_db_input(stripslashes($update_customer_state)) . "', billing_postcode = '" . tep_db_input($update_customer_postcode) . "', billing_country = '" . tep_db_input(stripslashes($update_customer_country)) . "',"; } $UpdateOrders .= "delivery_name = '" . tep_db_input(stripslashes($update_delivery_name)) . "', delivery_company = '" . tep_db_input(stripslashes($update_delivery_company)) . "', delivery_street_address = '" . tep_db_input(stripslashes($update_delivery_street_address)) . "', delivery_suburb = '" . tep_db_input(stripslashes($update_delivery_suburb)) . "', delivery_city = '" . tep_db_input(stripslashes($update_delivery_city)) . "', delivery_state = '" . tep_db_input(stripslashes($update_delivery_state)) . "', delivery_postcode = '" . tep_db_input($update_delivery_postcode) . "', delivery_country = '" . tep_db_input(stripslashes($update_delivery_country)) . "', payment_method = '" . tep_db_input($update_info_payment_method) . "', cc_type = '" . tep_db_input($update_info_cc_type) . "', cc_owner = '" . tep_db_input($update_info_cc_owner) . "',"; if(substr($update_info_cc_number,0,8) != "(Last 4)") { $UpdateOrders .= "cc_number = '$update_info_cc_number',"; } $UpdateOrders .= "cc_expires = '$update_info_cc_expires', orders_status = '" . tep_db_input($status) . "'"; if(!$CommentsWithStatus) { $UpdateOrders .= ", comments = '" . tep_db_input($comments) . "'"; } $UpdateOrders .= " where orders_id = '" . tep_db_input($oID) . "';"; tep_db_query($UpdateOrders); $order_updated = true; $check_status_query = tep_db_query("select customers_name, customers_email_address, orders_status, date_purchased from " . TABLE_ORDERS . " where orders_id = '" . (int)$oID . "'"); $check_status = tep_db_fetch_array($check_status_query); // 1.2 UPDATE STATUS HISTORY & SEND EMAIL TO CUSTOMER IF NECESSARY ##### if ($order->info['orders_status'] != $status) { // Notify Customer $customer_notified = '0'; if (isset($HTTP_POST_VARS['notify']) && ($HTTP_POST_VARS['notify'] == 'on')) { $notify_comments = ''; if (isset($HTTP_POST_VARS['notify_comments']) && ($HTTP_POST_VARS['notify_comments'] == 'on')) { $notify_comments = sprintf(EMAIL_TEXT_COMMENTS_UPDATE, $comments) . "\n\n"; } $email = STORE_NAME . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_TEXT_ORDER_NUMBER . ' ' . $oID . "\n" . EMAIL_TEXT_INVOICE_URL . ' ' . tep_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . $oID, 'SSL') . "\n" . EMAIL_TEXT_DATE_ORDERED . ' ' . tep_date_long($check_status['date_purchased']) . "\n\n" . $notify_comments . sprintf(EMAIL_TEXT_STATUS_UPDATE, $orders_status_array[$status]); tep_mail($check_status['customers_name'], $check_status['customers_email_address'], EMAIL_TEXT_SUBJECT, $email, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); $customer_notified = '1'; } // "Status History" table has gone through a few different changes, so here are different versions of the status update. // NOTE: Theoretically, there shouldn't be a orders_status field in the ORDERS table. It should really just use the latest value from this status history table. if($CommentsWithStatus) { tep_db_query("insert into " . TABLE_ORDERS_STATUS_HISTORY . " (orders_id, orders_status_id, date_added, customer_notified, comments) values ('" . tep_db_input($oID) . "', '" . tep_db_input($status) . "', now(), " . tep_db_input($customer_notified) . ", '" . tep_db_input($comments) . "')"); } else { if($OldNewStatusValues) { tep_db_query("insert into " . TABLE_ORDERS_STATUS_HISTORY . " (orders_id, new_value, old_value, date_added, customer_notified) values ('" . tep_db_input($oID) . "', '" . tep_db_input($status) . "', '" . $order->info['orders_status'] . "', now(), " . tep_db_input($customer_notified) . ")"); } else { tep_db_query("insert into " . TABLE_ORDERS_STATUS_HISTORY . " (orders_id, orders_status_id, date_added, customer_notified) values ('" . tep_db_input($oID) . "', '" . tep_db_input($status) . "', now(), " . tep_db_input($customer_notified) . ")"); } } } // 1.3 UPDATE PRODUCTS ##### $RunningSubTotal = 0; $RunningTax = 0; // Do pre-check for subtotal field existence (CWS) $ot_subtotal_found = false; foreach($update_totals as $total_details) { extract($total_details,EXTR_PREFIX_ALL,"ot"); if($ot_class == "ot_subtotal") { $ot_subtotal_found = true; break; } } // 1.3.1 Update orders_products Table foreach($update_products as $orders_products_id => $products_details) { // 1.3.1.1 Update Inventory Quantity $order = tep_db_fetch_array($order_query); if ($products_details["qty"] != $order['products_quantity']) { $quantity_difference = ($products_details["qty"] - $order['products_quantity']); tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = products_quantity - " . $quantity_difference . ", products_ordered = products_ordered + " . $quantity_difference . " where products_id = '" . (int)$order['products_id'] . "'"); } if($products_details["qty"] > 0) { // a.) quantity found --> add to list & sum $Query = "update " . TABLE_ORDERS_PRODUCTS . " set products_model = '" . $products_details["model"] . "', products_name = '" . str_replace("'", "'", $products_details["name"]) . "', final_price = '" . $products_details["final_price"] . "', products_tax = '" . $products_details["tax"] . "', products_quantity = '" . $products_details["qty"] . "' where orders_products_id = '$orders_products_id';"; tep_db_query($Query); // Update Tax and Subtotals: please choose sum WITH or WITHOUT tax, but activate only ONE version ;-) $RunningSubTotal += (tep_add_tax(($products_details["qty"] * $products_details["final_price"]), $products_details["tax"])*20)/20; // version WITH tax // $RunningSubTotal += $products_details["qty"] * $products_details["final_price"]; // version WITHOUT tax $RunningTax += (($products_details["tax"]/100) * ($products_details["qty"] * $products_details["final_price"])); // Update Any Attributes if(IsSet($products_details[attributes])) { foreach($products_details["attributes"] as $orders_products_attributes_id => $attributes_details) { $Query = "update " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " set products_options = '" . $attributes_details["option"] . "', products_options_values = '" . $attributes_details["value"] . "' where orders_products_attributes_id = '$orders_products_attributes_id';"; tep_db_query($Query); } } } else { // b.) null quantity found --> delete $Query = "delete from " . TABLE_ORDERS_PRODUCTS . " where orders_products_id = '$orders_products_id';"; tep_db_query($Query); $order = tep_db_fetch_array($order_query); if ($products_details["qty"] != $order['products_quantity']){ $quantity_difference = ($products_details["qty"] - $order['products_quantity']); tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = products_quantity - " . $quantity_difference . ", products_ordered = products_ordered + " . $quantity_difference . " where products_id = '" . (int)$order['products_id'] . "'"); } $Query = "delete from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_products_id = '$orders_products_id';"; tep_db_query($Query); } } // 1.4. UPDATE SHIPPING, DISCOUNT & CUSTOM TAXES ##### //print $RunningTax."prima <br>"; //print "<pre>"; //print_r($update_totals); //print "</pre>"; foreach($update_totals as $total_index => $total_details) { extract($total_details,EXTR_PREFIX_ALL,"ot"); //print_r($total_details)."<br>"; if ($ot_class == "ot_shipping") { $RunningTax += ($ot_value - ($ot_value / (1 + ($AddShippingTax / 100)))); // corrected tax by cb //$RunningTax += (($AddShippingTax / 100) * $ot_value); } elseif ($ot_class == "ot_lev_discount") { $RunningTax += ($ot_value - ($ot_value / (1 + ($AddLevelDiscountTax / 100)))); // corrected tax by cb // $RunningTax += (($AddLevelDiscountTax / 100) * $ot_value); } elseif ($ot_class == "ot_customer_discount") { $RunningTax += ($ot_value - ($ot_value / (1 + ($AddCustomerDiscountTax / 100)))); // corrected tax by cb // $RunningTax += (($AddCustomerDiscountTax / 100) * $ot_value); } elseif ($ot_class == "ot_custom") { $RunningTax += ($ot_value - ($ot_value / (1 + ($AddCustomTax / 100)))); // corrected tax by cb // $RunningTax += (($AddCustomTax / 100) * $ot_value); } elseif ($ot_class == "ot_cod_fee") { $RunningTax += ($ot_value - ($ot_value / (1 + ($AddCustomTax / 100)))); // corrected tax by cb // $RunningTax += (($AddCustomTax / 100) * $ot_value); } //print $RunningTax."<br>"; } // exit; // 1.5 UPDATE TOTALS ##### $RunningTotal = 0; $sort_order = 0; // 1.5.1 Do pre-check for Tax field existence $ot_tax_found = 0; foreach($update_totals as $total_details) { extract($total_details,EXTR_PREFIX_ALL,"ot"); if($ot_class == "ot_tax") { $ot_tax_found = 1; break; } } // 1.5.2. Summing up total foreach($update_totals as $total_index => $total_details) { // 1.5.2.1 Prepare Tax Insertion extract($total_details,EXTR_PREFIX_ALL,"ot"); // inserisce la tassa se non la trova oppure ?? if (trim(strtolower($ot_title)) == "iva" || trim(strtolower($ot_title)) == "iva:") { if ($ot_class != "ot_tax" && $ot_tax_found == 0) { // Inserting Tax $ot_class = "ot_tax"; $ot_value = "x"; // This gets updated in the next step $ot_tax_found = 1; } } // 1.5.2.2 Update ot_subtotal, ot_tax, and ot_total classes if (trim($ot_title) && trim($ot_value)) { $sort_order++; if ($ot_class == "ot_subtotal") { $ot_value = $RunningSubTotal; } if ($ot_class == "ot_tax") { $ot_value = $RunningTax; // print "ot_value = $ot_value<br>\n"; } // Check for existence of subtotals (CWS) if ($ot_class == "ot_total") { $ot_value = $RunningTotal-$RunningTax; if ( !$ot_subtotal_found ) { // There was no subtotal on this order, lets add the running subtotal in. // $ot_value += $RunningSubTotal; } // print $ot_value; // exit; } // Set $ot_text (display-formatted value) // $ot_text = "\$" . number_format($ot_value, 2, '.', ','); $order = new order($oID); $ot_text = $currencies->format($ot_value, true, $order->info['currency'], $order->info['currency_value']); if ($ot_class == "ot_total") { $ot_text = "<b>" . $ot_text . "</b>"; } if($ot_total_id > 0) { // Already in database --> Update $Query = 'UPDATE ' . TABLE_ORDERS_TOTAL . ' SET title = "' . $ot_title . '", text = "' . $ot_text . '", value = "' . $ot_value . '", sort_order = "' . $sort_order . '" WHERE orders_total_id = "' . $ot_total_id . '"'; tep_db_query($Query); } else { // New Insert $Query = 'INSERT INTO ' . TABLE_ORDERS_TOTAL . ' SET orders_id = "' . $oID . '", title = "' . $ot_title . '", text = "' . $ot_text . '", value = "' . $ot_value . '", class = "' . $ot_class . '", sort_order = "' . $sort_order . '"'; tep_db_query($Query); } $RunningTotal += $ot_value; // print $ot_value."<br>"; } elseif (($ot_total_id > 0) && ($ot_class != "ot_shipping")) { // Delete Total Piece $Query = "delete from " . TABLE_ORDERS_TOTAL . " where orders_total_id = '$ot_total_id'"; tep_db_query($Query); } } // print "Totale ".$RunningTotal; // exit; // 1.6 SUCCESS MESSAGE ##### if ($order_updated) { $messageStack->add_session(SUCCESS_ORDER_UPDATED, 'success'); } tep_redirect(tep_href_link("edit_orders.php", tep_get_all_get_params(array('action')) . 'action=edit')); break; // 2. ADD A PRODUCT ################################################################################ ############### case 'add_product': if($step == 5) { // 2.1 GET ORDER INFO ##### $oID = tep_db_prepare_input($HTTP_GET_VARS['oID']); $order = new order($oID); $AddedOptionsPrice = 0; // 2.1.1 Get Product Attribute Info if(IsSet($add_product_options)) { foreach($add_product_options as $option_id => $option_value_id) { $result = tep_db_query("SELECT * FROM " . TABLE_PRODUCTS_ATTRIBUTES . " pa LEFT JOIN " . TABLE_PRODUCTS_OPTIONS . " po ON po.products_options_id=pa.options_id LEFT JOIN " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov ON pov.products_options_values_id=pa.options_values_id WHERE products_id='$add_product_products_id' and options_id=$option_id and options_values_id=$option_value_id and po.language_id = '" . (int)$languages_id . "' and pov.language_id = '" . (int)$languages_id . "'"); $row = tep_db_fetch_array($result); extract($row, EXTR_PREFIX_ALL, "opt"); $AddedOptionsPrice += $opt_options_values_price; $option_value_details[$option_id][$option_value_id] = array ("options_values_price" => $opt_options_values_price); $option_names[$option_id] = $opt_products_options_name; $option_values_names[$option_value_id] = $opt_products_options_values_name; } } // 2.1.2 Get Product Info $InfoQuery = "select p.products_model,p.products_price,pd.products_name,p.products_tax_class_id from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on pd.products_id=p.products_id where p.products_id='$add_product_products_id' and pd.language_id = '" . (int)$languages_id . "'"; $result = tep_db_query($InfoQuery); $row = tep_db_fetch_array($result); extract($row, EXTR_PREFIX_ALL, "p"); // risolviamo il bug delle offerte $rs_offerte = tep_db_query("select * from specials where products_id ='". $add_product_products_id."'"); $offerte = tep_db_fetch_array($rs_offerte); if ($offerte) { $p_products_price = $offerte['specials_new_products_price']; } // Following functions are defined at the bottom of this file $CountryID = tep_get_country_id($order->delivery["country"]); $ZoneID = tep_get_zone_id($CountryID, $order->delivery["state"]); $ProductsTax = tep_get_tax_rate($p_products_tax_class_id, $CountryID, $ZoneID); // 2.2 UPDATE ORDER ##### $Query = "insert into " . TABLE_ORDERS_PRODUCTS . " set orders_id = $oID, products_id = $add_product_products_id, products_model = '$p_products_model', products_name = '" . str_replace("'", "'", $p_products_name) . "', products_price = '$p_products_price', final_price = '" . ($p_products_price + $AddedOptionsPrice) . "', products_tax = '$ProductsTax', products_quantity = $add_product_quantity;"; tep_db_query($Query); $new_product_id = tep_db_insert_id(); // 2.2.1 Update inventory Quantity tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = products_quantity - " . $add_product_quantity . ", products_ordered = products_ordered + " . $add_product_quantity . " where products_id = '" . $add_product_products_id . "'"); if (IsSet($add_product_options)) { foreach($add_product_options as $option_id => $option_value_id) { $Query = "insert into " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " set orders_id = $oID, orders_products_id = $new_product_id, products_options = '" . $option_names[$option_id] . "', products_options_values = '" . $option_values_names[$option_value_id] . "', options_values_price = '" . $option_value_details[$option_id][$option_value_id]["options_values_price"] . "', price_prefix = '+';"; tep_db_query($Query); } } // 2.2.2 Calculate Tax and Sub-Totals $order = new order($oID); $RunningSubTotal = 0; $RunningTax = 0; for ($i=0; $i<sizeof($order->products); $i++) { $RunningSubTotal += ($order->products[$i]['qty'] * $order->products[$i]['final_price']); $RunningTax += (($order->products[$i]['tax'] / 100) * ($order->products[$i]['qty'] * $order->products[$i]['final_price'])); } // 2.2.2.1 Tax $Query = "update " . TABLE_ORDERS_TOTAL . " set text = '" . number_format($RunningTax, 2, '.', ',') . $order->info['currency'] . "', value = '" . $RunningTax . "' where class='ot_tax' and orders_id=$oID"; tep_db_query($Query); // 2.2.2.2 Sub-Total $Query = "update " . TABLE_ORDERS_TOTAL . " set text = '" . number_format($RunningSubTotal + $RunningTax, 2, '.', ',') . $order->info['currency'] . "', value = '" . $RunningSubTotal . "' where class='ot_subtotal' and orders_id=$oID"; tep_db_query($Query); // 2.2.2.3 Total $Query = "select sum(value) as total_value from " . TABLE_ORDERS_TOTAL . " where class != 'ot_total' and orders_id=$oID"; $result = tep_db_query($Query); $row = tep_db_fetch_array($result); $Total = $row["total_value"]; $Query = "update " . TABLE_ORDERS_TOTAL . " set text = '<b>" . number_format($Total, 2, '.', ',') . $order->info['currency'] . "</b>', value = '" . $Total . "' where class='ot_total' and orders_id=$oID"; tep_db_query($Query); // 2.3 REDIRECTION ##### tep_redirect(tep_href_link("edit_orders.php", tep_get_all_get_params(array('action')) . 'action=edit')); } break; } } if (($action == 'edit') && isset($HTTP_GET_VARS['oID'])) { $oID = tep_db_prepare_input($HTTP_GET_VARS['oID']); $orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where orders_id = '" . (int)$oID . "'"); $order_exists = true; if (!tep_db_num_rows($orders_query)) { $order_exists = false; $messageStack->add(sprintf(ERROR_ORDER_DOES_NOT_EXIST, $oID), 'error'); } } ?> <!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> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF"> <!-- header //--> <?php require(DIR_WS_INCLUDES . 'header.php'); ?> <style type="text/css"> .Subtitle { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; font-weight: bold; color: #FF6600; } </style> <!-- 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"> <!-- left_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?> <!-- left_navigation_eof //--> </table></td> <!-- body_text //--> <td width="100%" valign="top"><table border="0" width="96%" cellspacing="0" cellpadding="2"> <?php if (($action == 'edit') && ($order_exists == true)) { $order = new order($oID); ?> <tr> <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading"><?php echo HEADING_TITLE; ?> (Nr. <?php echo $oID; ?> del <?php echo tep_datetime_short($order->info['date_purchased']); ?>)</td> <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', 1, HEADING_IMAGE_HEIGHT); ?></td> <td class="pageHeading" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('action'))) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td> </tr> <tr> <td class="main" colspan="3"><?php echo tep_draw_separator('pixel_trans.gif', '1', '1'); ?></td> </tr> <tr> <td class="main" colspan="3"><?php echo HEADING_SUBTITLE; ?></td> </tr> <tr> <td class="main" colspan="3"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> </table></td> </tr> <!-- Begin Addresses Block --> <tr><?php echo tep_draw_form('edit_order', "edit_orders.php", tep_get_all_get_params(array('action','paycc')) . 'action=update_order'); ?> <td class="SubTitle"><?php echo MENUE_TITLE_CUSTOMER; ?></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '1'); ?></td> </tr> <tr> <td> <table border="0" class="dataTableRow" cellpadding="2" cellspacing="0"> <tr class="dataTableHeadingRow"> <td class="dataTableHeadingContent" width="80"></td> <td class="dataTableHeadingContent" width="150"><?php echo ENTRY_BILLING_ADDRESS; ?></td> <td class="dataTableHeadingContent" width="6"> </td> <td class="dataTableHeadingContent" width="150"><?php echo ENTRY_SHIPPING_ADDRESS; ?></td> </tr> <tr> <td class="main"><b><?php echo ENTRY_CUSTOMER_COMPANY; ?>: </b></td> <td><span class="main"><input name="update_customer_company" size="25" value="<?php echo tep_html_quotes($order->customer['company']); ?>"></span></td> <td> </td> <td><span class="main"><input name="update_delivery_company" size="25" value="<?php echo tep_html_quotes($order->delivery['company']); ?>"></span></td> </tr> <tr> <td class="main"><b><?php echo ENTRY_CUSTOMER_NAME; ?>: </b></td> <td><span class="main"><input name="update_customer_name" size="25" value="<?php echo tep_html_quotes($order->customer['name']); ?>"></span></td> <td> </td> <td><span class="main"><input name="update_delivery_name" size="25" value="<?php echo tep_html_quotes($order->delivery['name']); ?>"></span></td> </tr> <tr> <td class="main"><b><?php echo ENTRY_CUSTOMER_ADDRESS; ?>: </b></td> <td><span class="main"><input name="update_customer_street_address" size="25" value="<?php echo tep_html_quotes($order->customer['street_address']); ?>"></span></td> <td> </td> <td><span class="main"><input name="update_delivery_street_address" size="25" value="<?php echo tep_html_quotes($order->delivery['street_address']); ?>"></span></td> </tr> <tr> <td class="main"><b><?php echo ENTRY_CUSTOMER_SUBURB; ?>: </b></td> <td><span class="main"><input name="update_customer_suburb" size="25" value="<?php echo tep_html_quotes($order->customer['suburb']); ?>"></span></td> <td> </td> <td><span class="main"><input name="update_delivery_suburb" size="25" value="<?php echo tep_html_quotes($order->delivery['suburb']); ?>"></span></td> </tr> <tr> <td class="main"><b><?php echo ENTRY_CUSTOMER_CITY; ?>: </b></td> <td><span class="main"><input name="update_customer_city" size="25" value="<?php echo tep_html_quotes($order->customer['city']); ?>"></span></td> <td> </td> <td><span class="main"><input name="update_delivery_city" size="25" value="<?php echo tep_html_quotes($order->delivery['city']); ?>"></span></td> </tr> <tr> <td class="main"><b><?php echo ENTRY_CUSTOMER_STATE; ?>: </b></td> <td><span class="main"><input name="update_customer_state" size="25" value="<?php echo tep_html_quotes($order->customer['state']); ?>"></span></td> <td> </td> <td><span class="main"><input name="update_delivery_state" size="25" value="<?php echo tep_html_quotes($order->delivery['state']); ?>"></span></td> </tr> <tr> <td class="main"><b><?php echo ENTRY_CUSTOMER_POSTCODE; ?>: </b></td> <td><span class="main"><input name="update_customer_postcode" size="25" value="<?php echo $order->customer['postcode']; ?>"></span></td> <td> </td> <td><span class="main"><input name="update_delivery_postcode" size="25" value="<?php echo $order->delivery['postcode']; ?>"></span></td> </tr> <tr> <td class="main"><b><?php echo ENTRY_CUSTOMER_COUNTRY; ?>: </b></td> <td><span class="main"><input name="update_customer_country" size="25" value="<?php echo tep_html_quotes($order->customer['country']); ?>"></span></td> <td> </td> <td><span class="main"><input name="update_delivery_country" size="25" value="<?php echo tep_html_quotes($order->delivery['country']); ?>"></span></td> </tr> <tr> <td class="main"><b><?php echo ENTRY_CUSTOMER_PHONE; ?>: </b></td> <td><span class="main"><input name="update_customer_telephone" size="25" value="<?php echo $order->customer['telephone']; ?>"></span></td> <td> </td> <td> </td> </tr> <tr> <td class="main"><b><?php echo ENTRY_CUSTOMER_EMAIL; ?>: </b></td> <td colspan="3"><span class="main"><input name="update_customer_email_address" size="25" value="<?php echo $order->customer['email_address']; ?>"></span></td> </tr> </table> </td> </tr> <!-- End Addresses Block --> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <!-- Begin Payment Block --> <tr> <td class="SubTitle"><?php echo MENUE_TITLE_PAYMENT; ?></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '1'); ?></td> </tr> <tr> <td> <table border="0" cellspacing="0" cellpadding="2" class="dataTableRow"> <tr class="dataTableHeadingRow"> <td colspan="2" class="dataTableHeadingContent"><?php echo ENTRY_PAYMENT_METHOD; ?></td> </tr> <tr> <td colspan="2" class="main"><input name='update_info_payment_method' size='35' value='<?php echo $order->info['payment_method']; ?>'></td> </tr> <!-- Begin Credit Card Info Block --> <?php if ($order->info['cc_type'] || $order->info['cc_owner'] || $order->info['cc_number'] || $order->info['payment_method'] == "Credit Card" || $order->info['payment_method'] == "Kreditkarte") { ?> <tr> <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <tr> <td class="main"><?php echo ENTRY_CREDIT_CARD_TYPE; ?></td> <td class="main"><input name='update_info_cc_type' size='10' value='<?php echo $order->info['cc_type']; ?>'></td> </tr> <tr> <td class="main"><?php echo ENTRY_CREDIT_CARD_OWNER; ?></td> <td class="main"><input name='update_info_cc_owner' size='20' value='<?php echo $order->info['cc_owner']; ?>'></td> </tr> <tr> <td class="main"><?php echo ENTRY_CREDIT_CARD_NUMBER; ?></td> <td class="main"><input name='update_info_cc_number' size='20' value='<?php echo $order->info['cc_number']; ?>'></td> </tr> <tr> <td class="main"><?php echo ENTRY_CREDIT_CARD_EXPIRES; ?></td> <td class="main"><input name='update_info_cc_expires' size='4' value='<?php echo $order->info['cc_expires']; ?>' maxlength="4"></td> </tr> <?php } ?> <!-- End Credit Card Info Block --> </table> </td> </tr> <?php if ($order->info['payment_method'] != "Credit Card" || $order->info['payment_method'] != "Kreditkarte") { ?> <tr> <td class="smalltext"></td> </tr> <?php } ?> <!-- End Payment Block --> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <!-- Begin Products Listing Block --> <tr> <td class="SubTitle"><?php echo MENUE_TITLE_ORDER; ?></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '1'); ?></td> </tr> <tr> <td> <?php // Override order.php Class's Field Limitations $index = 0; $order->products = array(); $orders_products_query = tep_db_query("select * from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$oID . "'"); while ($orders_products = tep_db_fetch_array($orders_products_query)) { $order->products[$index] = array('qty' => $orders_products['products_quantity'], 'name' => str_replace("'", "'", $orders_products['products_name']), 'model' => $orders_products['products_model'], 'tax' => $orders_products['products_tax'], 'price' => $orders_products['products_price'], 'final_price' => $orders_products['final_price'], 'orders_products_id' => $orders_products['orders_products_id']); $subindex = 0; $attributes_query_string = "select * from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$oID . "' and orders_products_id = '" . (int)$orders_products['orders_products_id'] . "'"; $attributes_query = tep_db_query($attributes_query_string); if (tep_db_num_rows($attributes_query)) { while ($attributes = tep_db_fetch_array($attributes_query)) { $order->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options'], 'value' => $attributes['products_options_values'], 'prefix' => $attributes['price_prefix'], 'price' => $attributes['options_values_price'], 'orders_products_attributes_id' => $attributes['orders_products_attributes_id']); $subindex++; } } $index++; } ?> <?php // Version with editable names & prices ?> <?php /* <table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr class="dataTableHeadingRow"> <td class="dataTableHeadingContent" width="20"><?php echo TABLE_HEADING_QUANTITY; ?></td> <td class="dataTableHeadingContent" width="5"> </td> <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCTS; ?></td> <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCTS_MODEL; ?></td> <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_TAX; ?></td> <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_UNIT_PRICE; ?></td> <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_UNIT_PRICE_TAXED; ?></td> <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_TOTAL_PRICE; ?></td> <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_TOTAL_PRICE_TAXED; ?></td> </tr> <?php for ($i=0; $i<sizeof($order->products); $i++) { $orders_products_id = $order->products[$i]['orders_products_id']; $RowStyle = "dataTableContent"; echo ' <tr class="dataTableRow">' . "\n" . ' <td class="' . $RowStyle . '" align="right">' . "<input name='update_products[$orders_products_id][qty]' size='2' value='" . $order->products[$i]['qty'] . "'> x</td>\n" . ' <td class="' . $RowStyle . '"></td>' . ' <td class="' . $RowStyle . '">' . "<input name='update_products[$orders_products_id][name]' size='64' value='" . $order->products[$i]['name'] . "'>"; // Has Attributes? if (sizeof($order->products[$i]['attributes']) > 0) { for ($j=0; $j<sizeof($order->products[$i]['attributes']); $j++) { $orders_products_attributes_id = $order->products[$i]['attributes'][$j]['orders_products_attributes_id']; echo '<br><nobr><small> <i> - ' . "<input name='update_products[$orders_products_id][attributes][$orders_products_attributes_id][option]' size='32' value='" . $order->products[$i]['attributes'][$j]['option'] . "'>" . ': ' . "<input name='update_products[$orders_products_id][attributes][$orders_products_attributes_id][value]' size='25' value='" . $order->products[$i]['attributes'][$j]['value']; if ($order->products[$i]['attributes'][$j]['price'] != '0') echo ' (' . $order->products[$i]['attributes'][$j]['prefix'] . $currencies->format($order->products[$i]['attributes'][$j]['price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . ')'; echo "'>"; echo '</i></small></nobr>'; } } echo ' </td>' . "\n" . ' <td class="' . $RowStyle . '">' . "<input name='update_products[$orders_products_id][model]' size='12' value='" . $order->products[$i]['model'] . "'>" . '</td>' . "\n" . ' <td class="' . $RowStyle . '">' . "<input name='update_products[$orders_products_id][tax]' size='3' value='" . tep_display_tax_value($order->products[$i]['tax']) . "'>" . '%</td>' . "\n" . ' <td class="' . $RowStyle . '" align="right">' . "<input name='update_products[$orders_products_id][final_price]' size='5' value='" . number_format($order->products[$i]['final_price'], 2, '.', '') . "'>" . '</td>' . "\n" . ' <td class="' . $RowStyle . '" align="right">' . $currencies->format($order->products[$i]['final_price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . '</td>' . "\n" . ' </tr>' . "\n"; } ?> </table> */ ?> <?php // Version without editable names & prices ?> <table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr class="dataTableHeadingRow"> <td class="dataTableHeadingContent" width="20"><?php echo TABLE_HEADING_QUANTITY; ?></td> <td class="dataTableHeadingContent" width="5"> </td> <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCTS; ?></td> <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCTS_MODEL; ?></td> <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_TAX; ?></td> <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_UNIT_PRICE; ?></td> <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_UNIT_PRICE_TAXED; ?></td> <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_TOTAL_PRICE; ?></td> <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_TOTAL_PRICE_TAXED; ?></td> </tr> <?php for ($i=0; $i<sizeof($order->products); $i++) { $orders_products_id = $order->products[$i]['orders_products_id']; $RowStyle = "dataTableContent"; echo ' <tr class="dataTableRow">' . "\n" . ' <td class="' . $RowStyle . '" align="left" width="20">' . "<input name='update_products[$orders_products_id][qty]' size='2' value='" . $order->products[$i]['qty'] . "'></td>\n" . ' <td class="' . $RowStyle . '" width="5"> x </td>' . ' <td class="' . $RowStyle . '">' . $order->products[$i]['name'] . "<input name='update_products[$orders_products_id][name]' size='64' type='hidden' value='" . $order->products[$i]['name'] . "'>"; // Has Attributes? if (sizeof($order->products[$i]['attributes']) > 0) { for ($j=0; $j<sizeof($order->products[$i]['attributes']); $j++) { $orders_products_attributes_id = $order->products[$i]['attributes'][$j]['orders_products_attributes_id']; echo '<br><nobr><small> <i> - ' . "<input name='update_products[$orders_products_id][attributes][$orders_products_attributes_id][option]' size='32' value='" . $order->products[$i]['attributes'][$j]['option'] . "'>" . ': ' . "<input name='update_products[$orders_products_id][attributes][$orders_products_attributes_id][value]' size='25' value='" . $order->products[$i]['attributes'][$j]['value']; if ($order->products[$i]['attributes'][$j]['price'] != '0') echo ' (' . $order->products[$i]['attributes'][$j]['prefix'] . $currencies->format($order->products[$i]['attributes'][$j]['price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . ')'; echo "'>"; echo '</i></small></nobr>'; } } echo ' </td>' . "\n" . ' <td class="' . $RowStyle . '">' . $order->products[$i]['model'] . "<input name='update_products[$orders_products_id][model]' size='12' type='hidden' value='" . $order->products[$i]['model'] . "'>" . '</td>' . "\n" . ' <td class="' . $RowStyle . '">' . "<input name='update_products[$orders_products_id][tax]' size='3' value='" . tep_display_tax_value($order->products[$i]['tax']) . "'>" . '%</td>' . "\n" . ' <td class="' . $RowStyle . '" align="right">' . $currencies->format($order->products[$i]['final_price']) . "<input name='update_products[$orders_products_id][final_price]' size='5' type='hidden' value='" . $order->products[$i]['final_price'] . "'>" . '</td>' . "\n" . ' <td class="' . $RowStyle . '" align="right">' . $currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']) . '</td>' . "\n" . ' <td class="' . $RowStyle . '" align="right">' . $currencies->format($order->products[$i]['final_price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . '</td>' . "\n" . ' <td class="' . $RowStyle . '" align="right"><b>' . $currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . '</b></td>' . "\n" . ' </tr>' . "\n"; } ?> </table> </td> <tr> <td> <table width="100%" cellpadding="0" cellspacing="0"> <tr> <td valign="top"><?php echo "<span class='smalltext'>" . HINT_DELETE_POSITION . "</span>"; ?></td> <td align="right"><?php echo '<a href="' . $PHP_SELF . '?oID=' . $oID . '&action=add_product&step=1">' . tep_image_button('button_add_article.gif', ADDING_TITLE) . '</a>'; ?></td> </tr> </t Quote Link to comment Share on other sites More sharing options...
sakkiotto Posted April 5, 2005 Share Posted April 5, 2005 (edited) Hi... i have installed this contrib but i have problem with curriences... see below the screenshot ... $ and ? ... i need only ? Edited April 5, 2005 by sakkiotto Quote Link to comment Share on other sites More sharing options...
1Putts Posted April 5, 2005 Share Posted April 5, 2005 Hi, I had the same problem and found out that this contrib doesn't work well on servers with register_globals turned off in php.ini . In old versions of php register_globals was turned on by default, but this has been changed because of security issues. Adding the following to the top of edit_orders.php (AFTER "<?" ) should resolve the issue, allthough a complete rewrite of the mod would be best. Henning, I for one want to thank you for figuring out the register globals problem. I suspected that was where my problems were but I just didn't know how to fix it. Finally, the order editor works for me (well, sort of). The only issue I have now is the "tax on shipping" calculation. I see in the code (admin/edit_orders.php) where it allows you to fill in the tax percentage: // Optional Tax Rate/Percent $AddShippingTax = "0.0"; // e.g. shipping tax of 17.5% is "17.5" My problem is my tax rate varies depending on where the customer is located. If someone could figure out how to replace the hard coded $AddShippingTax to something where it actually uses the appropriate tax zones (and accompanying tax rate), I would be a very happy person. But thanks again for figuring out that problem...it's a big help. Quote Link to comment Share on other sites More sharing options...
Guest Posted April 6, 2005 Share Posted April 6, 2005 Nobody have a answer for my question?? Please help! Peter :'( Still having problems of the final total being doubled whenever I hit the 'update' button.. doesn't matter what I change in the order.... Anybody have a solution to this problem? Thanks! <{POST_SNAPBACK}> Quote Link to comment Share on other sites More sharing options...
1Putts Posted April 9, 2005 Share Posted April 9, 2005 My problem is my tax rate varies depending on where the customer is located. If someone could figure out how to replace the hard coded $AddShippingTax to something where it actually uses the appropriate tax zones (and accompanying tax rate), I would be a very happy person. But thanks again for figuring out that problem...it's a big help. <{POST_SNAPBACK}> I managed to futz my way to a fix. For those using the order editor contribution and need the shipping tax to be applied in the same manner (ie. the exact same percentage of tax) as the product tax, here's what I did (note, I'm using v1.59): Around line 69, find this: // Optional Tax Rate/Percent $AddShippingTax = "0.0"; // e.g. shipping tax of 17.5% is "17.5" and either comment out the second line or just delete the whole thing. Next, find these lines (around 242): // Update Tax and Subtotals $RunningSubTotal += $products_details["qty"] * $products_details["final_price"]; $RunningTax += (($products_details["tax"]/100) * ($products_details["qty"] * $products_details["final_price"])); And add the following directly below: $AddShippingTax = $products_details["tax"]; Once again - this is only useful if the amount of tax you apply on shipping is the same as the amount you apply on products. Here in Canada, depending on where the customer is located, the tax rate varies. But whatever the tax rate applies, that is what is added to both the product and shipping costs. Quote Link to comment Share on other sites More sharing options...
Benm Posted April 21, 2005 Share Posted April 21, 2005 I have a, probably similar, issue with tax. VAT (BTW) seems to be added twice: Once to the product itself, and then again to the total. Example: The total order amount should be 49.50, not 57.40 The sub-total can be inclusive or exclusive of VAT, that doesn't really matter to me, but the total has to be correct. One problem is that I cannot use any hacks where the tax-rate is hardcoded, since we have some products with 19% and others with 6% tax. Is there any way to get this all right? Quote Link to comment Share on other sites More sharing options...
Benm Posted April 21, 2005 Share Posted April 21, 2005 Some additional info: The error is strictly in the entry for the order total. Here you can see 2 orders (ID 30 and 31), where 30 is correct (as entered without editing), and 31 is incorrect - this error presents as soon as you edit an order. PS: The shipping cost of order 30 have nothing to do with it whatsoever, i've verified that. Quote Link to comment Share on other sites More sharing options...
netstep Posted May 11, 2005 Share Posted May 11, 2005 What will it take to display the shipping and payment modules just like a customer would see on the public side? Quote Sam M. - Seattle Link to comment Share on other sites More sharing options...
smokestack Posted May 11, 2005 Share Posted May 11, 2005 I think the order editor tool is great but if you can't get the payment modules & shipping modules integrated so that the admin can process payment, then an invoice should be generated that can be emailed to the customer so that they can pay the difference (if required). Quote Link to comment Share on other sites More sharing options...
esquat Posted June 1, 2005 Share Posted June 1, 2005 Just a remark: Order Editor 1.61 has near line 360 under paragraph "1.5.2. Summing up total" the following code: if ($ot_class != "ot_tax" && $ot_tax_found == 0) { // Inserting Tax $ot_class = "ot_tax"; $ot_value = "x"; // This gets updated in the next step $ot_tax_found = 1; } This will prevent ot_subtotals from being processed when there is no ot_tax - which happens all the time when shipping from Europe to, say, the USA. The program should not make the assumption that a tax is always needed. Best, Ted Quote Link to comment Share on other sites More sharing options...
Guest Posted June 6, 2005 Share Posted June 6, 2005 Does anyonoe have this contribtuion working with PWA .082? Danny Quote Link to comment Share on other sites More sharing options...
nmlloyd Posted June 11, 2005 Share Posted June 11, 2005 I want to install this contribution but it is almost impossible to tell which is the best one to install as the contribution seems to have diversified into several different solutions. I can see 1.61 mentioned on this forum but on the contribution download page there is no mention of 1.61. There is a 1.6 and a 1.6a but no 1.61! Also 1.56 seems to still be in active use. Basically I am runnning a UK site for UK domestic orders only. All my order items carry a single tax/VAT rate. I want to be able to add/modify/delete items and override the shipping charges. Any advice from order editor experts welcome! Quote Link to comment Share on other sites More sharing options...
Guest Posted June 14, 2005 Share Posted June 14, 2005 I have the contribution installed as part of the step by step manual order entry contribution. In section 3 ordered products I have a problem with the tax calculation (in my case vat). When I edit an order or create one manually the price (.excl) is displayed with the vat, tax field is displayed correctly as 17.5% then the price(.incl) is calculated as the vat inclusive price with vat added again! In section 4 Discount,shipping and total The problem is then compounded because the sub total uses the total(.incl) from section 3 and adds vat again!! Thus each product ends up with 3 lots of compounded vat. I've had a look around the edit_orders.php file and I guess that I need some kind of mod to the UPDATE PRODUCTS , 1.4. UPDATE SHIPPING, DISCOUNT & CUSTOM TAXES, and 1.5 UPDATE TOTALS sections. Can any one help with this. I've copied those sections and pasted below. Finally, if I set the tax field to 0 all the totals display the price including vat. Hhhmmmm... // 1.3 UPDATE PRODUCTS ##### $RunningSubTotal = 0; $RunningTax = 0; // Do pre-check for subtotal field existence (CWS) $ot_subtotal_found = false; foreach($update_totals as $total_details) { extract($total_details,EXTR_PREFIX_ALL,"ot"); if($ot_class == "ot_subtotal") { $ot_subtotal_found = true; break; } } // 1.3.1 Update orders_products Table foreach($update_products as $orders_products_id => $products_details) { // 1.3.1.1 Update Inventory Quantity $order = tep_db_fetch_array($order_query); if ($products_details["qty"] != $order['products_quantity']) { $quantity_difference = ($products_details["qty"] - $order['products_quantity']); tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = products_quantity - " . $quantity_difference . ", products_ordered = products_ordered + " . $quantity_difference . " where products_id = '" . (int)$order['products_id'] . "'"); } if($products_details["qty"] > 0) { // a.) quantity found --> add to list & sum $Query = "update " . TABLE_ORDERS_PRODUCTS . " set products_model = '" . $products_details["model"] . "', products_name = '" . str_replace("'", "'", $products_details["name"]) . "', final_price = '" . $products_details["final_price"] . "', products_tax = '" . $products_details["tax"] . "', products_quantity = '" . $products_details["qty"] . "' where orders_products_id = '$orders_products_id';"; tep_db_query($Query); // Update Tax and Subtotals: please choose sum WITH or WITHOUT tax, but activate only ONE version ;-) // Correction tax calculation (Michel Haase, 2005-02-18) // -> correct calculation, but why there is a division by 20 and afterwards a mutiplication with 20 ??? // -> no changes made $RunningSubTotal += (tep_add_tax(($products_details["qty"] * $products_details["final_price"]), $products_details["tax"])*20)/20; // version WITH tax // $RunningSubTotal += $products_details["qty"] * $products_details["final_price"]; // version WITHOUT tax $RunningTax += (($products_details["tax"]/100) * ($products_details["qty"] * $products_details["final_price"])); // Update Any Attributes if(IsSet($products_details[attributes])) { foreach($products_details["attributes"] as $orders_products_attributes_id => $attributes_details) { $Query = "update " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " set products_options = '" . $attributes_details["option"] . "', products_options_values = '" . $attributes_details["value"] . "' where orders_products_attributes_id = '$orders_products_attributes_id';"; tep_db_query($Query); } } } else { // b.) null quantity found --> delete $Query = "delete from " . TABLE_ORDERS_PRODUCTS . " where orders_products_id = '$orders_products_id';"; tep_db_query($Query); $order = tep_db_fetch_array($order_query); if ($products_details["qty"] != $order['products_quantity']){ $quantity_difference = ($products_details["qty"] - $order['products_quantity']); tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = products_quantity - " . $quantity_difference . ", products_ordered = products_ordered + " . $quantity_difference . " where products_id = '" . (int)$order['products_id'] . "'"); } $Query = "delete from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_products_id = '$orders_products_id';"; tep_db_query($Query); } } // 1.4. UPDATE SHIPPING, DISCOUNT & CUSTOM TAXES ##### //print $RunningTax."prima <br>"; //print "<pre>"; //print_r($update_totals); //print "</pre>"; foreach($update_totals as $total_index => $total_details) { extract($total_details,EXTR_PREFIX_ALL,"ot"); //print_r($total_details)."<br>"; // Correction tax calculation (Michel Haase, 2005-02-18) // -> $AddShippingTax was set to '0.0' above (no shipping tax in Germany / in our shop) // -> no changes made // -> all other calculations here have not been checked if ($ot_class == "ot_shipping") { $RunningTax += ($ot_value - ($ot_value / (1 + ($AddShippingTax / 100)))); // corrected tax by cb //$RunningTax += (($AddShippingTax / 100) * $ot_value); } elseif ($ot_class == "ot_lev_discount") { $RunningTax += ($ot_value - ($ot_value / (1 + ($AddLevelDiscountTax / 100)))); // corrected tax by cb // $RunningTax += (($AddLevelDiscountTax / 100) * $ot_value); } elseif ($ot_class == "ot_customer_discount") { $RunningTax += ($ot_value - ($ot_value / (1 + ($AddCustomerDiscountTax / 100)))); // corrected tax by cb // $RunningTax += (($AddCustomerDiscountTax / 100) * $ot_value); } elseif ($ot_class == "ot_custom") { $RunningTax += ($ot_value - ($ot_value / (1 + ($AddCustomTax / 100)))); // corrected tax by cb // $RunningTax += (($AddCustomTax / 100) * $ot_value); } elseif ($ot_class == "ot_cod_fee") { $RunningTax += ($ot_value - ($ot_value / (1 + ($AddCustomTax / 100)))); // corrected tax by cb // $RunningTax += (($AddCustomTax / 100) * $ot_value); } //print $RunningTax."<br>"; } // exit; // 1.5 UPDATE TOTALS ##### $RunningTotal = 0; $sort_order = 0; // 1.5.1 Do pre-check for Tax field existence $ot_tax_found = 0; foreach($update_totals as $total_details) { extract($total_details,EXTR_PREFIX_ALL,"ot"); if($ot_class == "ot_tax") { $ot_tax_found = 1; break; } } // 1.5.2. Summing up total foreach($update_totals as $total_index => $total_details) { // 1.5.2.1 Prepare Tax Insertion extract($total_details,EXTR_PREFIX_ALL,"ot"); // inserisce la tassa se non la trova oppure ?? if (trim(strtolower($ot_title)) == "iva" || trim(strtolower($ot_title)) == "iva:") { if ($ot_class != "ot_tax" && $ot_tax_found == 0) { // Inserting Tax $ot_class = "ot_tax"; $ot_value = "x"; // This gets updated in the next step $ot_tax_found = 1; } } // 1.5.2.2 Update ot_subtotal, ot_tax, and ot_total classes if (trim($ot_title) && trim($ot_value)) { $sort_order++; if ($ot_class == "ot_subtotal") { $ot_value = $RunningSubTotal; } if ($ot_class == "ot_tax") { $ot_value = $RunningTax; // print "ot_value = $ot_value<br>\n"; } // Check for existence of subtotals (CWS) if ($ot_class == "ot_total") { // Correction tax calculation (Michel Haase, 2005-02-18) // I can't find out, WHERE the $RunningTotal is calculated - but the subtraction of the tax was wrong (in our shop) // $ot_value = $RunningTotal-$RunningTax; $ot_value = $RunningTotal; if ( !$ot_subtotal_found ) { // There was no subtotal on this order, lets add the running subtotal in. // $ot_value += $RunningSubTotal; } // print $ot_value; // exit; } // Set $ot_text (display-formatted value) // Correction of number_format - German format (Michel Haase, 2005-02-18) // $ot_text = "\$" . number_format($ot_value, 2, ',', ''); $order = new order($oID); $ot_text = $currencies->format($ot_value, true, $order->info['currency'], $order->info['currency_value']); if ($ot_class == "ot_total") { $ot_text = "<b>" . $ot_text . "</b>"; } if($ot_total_id > 0) { // Already in database --> Update $Query = 'UPDATE ' . TABLE_ORDERS_TOTAL . ' SET title = "' . $ot_title . '", text = "' . $ot_text . '", value = "' . $ot_value . '", sort_order = "' . $sort_order . '" WHERE orders_total_id = "' . $ot_total_id . '"'; tep_db_query($Query); } else { // New Insert $Query = 'INSERT INTO ' . TABLE_ORDERS_TOTAL . ' SET orders_id = "' . $oID . '", title = "' . $ot_title . '", text = "' . $ot_text . '", value = "' . $ot_value . '", class = "' . $ot_class . '", sort_order = "' . $sort_order . '"'; tep_db_query($Query); } $RunningTotal += $ot_value; // print $ot_value."<br>"; } elseif (($ot_total_id > 0) && ($ot_class != "ot_shipping")) { // Delete Total Piece $Query = "delete from " . TABLE_ORDERS_TOTAL . " where orders_total_id = '$ot_total_id'"; tep_db_query($Query); } } // print "Totale ".$RunningTotal; // exit; Quote Link to comment Share on other sites More sharing options...
Guest Posted June 14, 2005 Share Posted June 14, 2005 Have managed to part solve my problem. In that got the tax calculations to work in both the ordered products and the Discount, Shipping and Total sections. Only issue remaining is getting the correct net starting price for each product. ie I want the price (excl.) to be the net price as set up in my catalog and as appears in the products_price field of the products table. I'm convinced it must be in the edit_orders.php file but can't seem to locate it. Can anyone point it out to me please. Quote Link to comment Share on other sites More sharing options...
nmlloyd Posted June 15, 2005 Share Posted June 15, 2005 I installed V1.61 and amended all of the hard coded tax rates to 17.5 as UK VAT is 17.5% on goods, shipping, discounts and everything. In my store, prices are quoted net of tax (vat) and VAT is added to both goods and shipping charges. e.g. the following totals would be correct Goods Sub Total ?90.00 Shipping charges ?10.00 VAT @ 17.5% ?17.50 Total ?117.50 OE 1.61 calculates the VAT correctly on the goods (?90 * (17.5 / 100)) but incorrectly on the shipping charges where it calculates VAT as ?10 - (?10 / (1 + (17.5 /100))) = ?1.489 the VAT calculation on shipping should simply be (?10 * (17.5 / 100)) = ?1.75 There is no logical reason to calculate VAT differently on totals than products. Someone has introduced a bug into the tax calculation coding when the original code seems to be correct! Worse still the faulty code is commented "// corrected tax by cb"! I think this contribution is pretty good overall but there is too much hard coding of tax rates (e.g. the 20.0 and 7.6) and too many people have tried to fix things by applying and publishing code that just applies to their store which they may not have configured logically anyway. The faulty 1.61 code is shown below if ($ot_class == "ot_shipping") { $RunningTax += ($ot_value - ($ot_value / (1 + ($AddShippingTax / 100)))); // corrected tax by cb //$RunningTax += (($AddShippingTax / 100) * $ot_value); } elseif ($ot_class == "ot_lev_discount") { $RunningTax += ($ot_value - ($ot_value / (1 + ($AddLevelDiscountTax / 100)))); // corrected tax by cb // $RunningTax += (($AddLevelDiscountTax / 100) * $ot_value); } elseif ($ot_class == "ot_customer_discount") { $RunningTax += ($ot_value - ($ot_value / (1 + ($AddCustomerDiscountTax / 100)))); // corrected tax by cb // $RunningTax += (($AddCustomerDiscountTax / 100) * $ot_value); } elseif ($ot_class == "ot_custom") { $RunningTax += ($ot_value - ($ot_value / (1 + ($AddCustomTax / 100)))); // corrected tax by cb // $RunningTax += (($AddCustomTax / 100) * $ot_value); } elseif ($ot_class == "ot_cod_fee") { $RunningTax += ($ot_value - ($ot_value / (1 + ($AddCustomTax / 100)))); // corrected tax by cb // $RunningTax += (($AddCustomTax / 100) * $ot_value); Corrected code (Just remove the "fix" applied by cb!) if ($ot_class == "ot_shipping") { $RunningTax += (($AddShippingTax / 100) * $ot_value); } elseif ($ot_class == "ot_lev_discount") { $RunningTax += (($AddLevelDiscountTax / 100) * $ot_value); } elseif ($ot_class == "ot_customer_discount") { $RunningTax += (($AddCustomerDiscountTax / 100) * $ot_value); } elseif ($ot_class == "ot_custom") { $RunningTax += (($AddCustomTax / 100) * $ot_value); } elseif ($ot_class == "ot_cod_fee") { $RunningTax += (($AddCustomTax / 100) * $ot_value); } Quote Link to comment Share on other sites More sharing options...
nmlloyd Posted June 15, 2005 Share Posted June 15, 2005 Oh and the fix I applied was to the order total update where my order totals were excluding the VAT that was now calculated correctly // $ot_value = $RunningTotal-$RunningTax; (removed NML) $ot_value = $RunningTotal; // NML order total correction to include VAT Quote Link to comment Share on other sites More sharing options...
Guest Posted June 16, 2005 Share Posted June 16, 2005 Martin Thank for the 2 useful posts above. I implemented them and they work exactly as you say. How did you manage to get the vat excl. price when adding a product. Everytime I add a product it always gives me the vat incl. price and then adds vat again! All my products are are shown in the store as vat incl. Is there something that you changed in the edit_order file? Marc Quote Link to comment Share on other sites More sharing options...
Guest Posted June 16, 2005 Share Posted June 16, 2005 I should have also said above that I have the products with the vat excl. price in my catalog. Quote Link to comment Share on other sites More sharing options...
nmlloyd Posted June 16, 2005 Share Posted June 16, 2005 Mark, The plot thickens! In my stores I have VAT exclusive prices in the catalogue and I display VAT exclusive prices in the store, so the difference with your store is you display VAT inclusive prices. My guess is that OE 1.61 is pulling in the store displayed prices (which in your case includes VAT), and then calculating VAT again. This probably accounts for some of the weird fixes that people have tried to apply where they have tried to take the VAT off again to make the end result what they wanted. Probably what needs to happen is that the order editor needs to pull in the VAT exclusive prices, and then it would be OK to calculate and add the VAT again. I am only guessing here as I have not looked at the code that pulls in the item prices. I did not change the edit_order.php file from 1.61 other than as stated in my earlier posts. Quote Link to comment Share on other sites More sharing options...
valdier Posted June 17, 2005 Share Posted June 17, 2005 Not sure exactly what is going on for me, but after installing this, going to the specific order page, all I ever get when clicking on the "Edit" button is: Access Denied No Right Permission Access Please contact your Web Administrator to request more access or if you found any problem. Any ideas why this may be happening? As a note, the account is Top Administrator. Quote Link to comment Share on other sites More sharing options...
Guest Posted June 21, 2005 Share Posted June 21, 2005 Martin Thanks for help. I'll have to try and find where OE pulls the price and have it point to the excl. price. If you happen to come across it, let me know. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.