Re: Edit Orders v4.0 Support Thread
Quote:
Originally Posted by
lat9
Does anyone have a merged version of /YOUR_ADMIN/orders.php that includes the changes for Edit Orders 4.1 and Ty Package Tracker 3.13?
Never mind on the merge; I finally got that sorted out.
Running Edit Orders 4.1 w/ Ty Package Tracker on Zen Cart v1.5.1, PHP v5.4.8.
Whenever I click on the Edit button in the Customers->Orders display, I receive the following debug log:
Code:
[06-Jul-2013 14:32:15 Europe/Berlin] PHP Warning: Illegal string offset 'id' in C:\xampp\htdocs\zc_151\includes\modules\shipping\freeshipper.php on line 32
[06-Jul-2013 14:32:15 Europe/Berlin] PHP Warning: Illegal string offset 'iso_code_2' in C:\xampp\htdocs\zc_151\includes\modules\shipping\usps.php on line 1248
[06-Jul-2013 14:32:15 Europe/Berlin] PHP Warning: Illegal string offset 'iso_code_2' in C:\xampp\htdocs\zc_151\includes\modules\shipping\usps.php on line 1262
[06-Jul-2013 14:32:15 Europe/Berlin] PHP Warning: Illegal string offset 'id' in C:\xampp\htdocs\zc_151\includes\modules\shipping\freeshipper.php on line 32
[06-Jul-2013 14:32:15 Europe/Berlin] PHP Warning: Illegal string offset 'iso_code_2' in C:\xampp\htdocs\zc_151\includes\modules\shipping\usps.php on line 1248
[06-Jul-2013 14:32:15 Europe/Berlin] PHP Warning: Illegal string offset 'iso_code_2' in C:\xampp\htdocs\zc_151\includes\modules\shipping\usps.php on line 1262
The two shipping modules that I've got enabled are (you guessed it), Free Shipping and USPS. The issue is that when the shipping modules are loaded under edit_orders, the global variable $order->delivery['country'] is a string containing the country's name. When the shipping modules are loaded from the store-front, $order->delivery['country'] is an array:
Code:
country (array)
id (string) => 223
title (string) => United States
iso_code_2 (string) => US
iso_code_3 (string) => USA
I'm not sure if the following is the 'best' way to correct the problem ... but it works! Changes made to \YOUR_ADMIN\includes\functions\extra_functions\edit_orders_functions.php:
Code:
function eo_get_available_shipping_modules() {
$retval = array();
if(defined('MODULE_SHIPPING_INSTALLED') && zen_not_null(MODULE_SHIPPING_INSTALLED)) {
//-bof-a-lat9-illegal-string-offset
global $order, $db;
if (!isset($order)) {
error_log('/includes/functions/extra_functions/edit_orders_functions.php (eo_get_available_shipping_modules()): global $order not set');
die();
}
$country_info = $db->Execute('SELECT countries_id as id, countries_name as name, countries_iso_code_2 as iso_code_2, countries_iso_code_3 as iso_code_3 FROM ' . TABLE_COUNTRIES . " WHERE countries_name = '" . $order->delivery['country'] . "'");
$order->delivery['country'] = $country_info->fields;
unset($country_info);
//-eof-a-lat9-illegal-string-offset
if(!isset($_SESSION['cart'])) {
require_once(DIR_FS_CATALOG . DIR_WS_CLASSES . 'shopping_cart.php');
$_SESSION['cart'] = new shoppingCart();
}
// Load the shipping class into the globals
require_once(DIR_FS_CATALOG . DIR_WS_CLASSES . 'shipping.php');
$shipping_modules = new shipping();
for($i=0, $n=count($shipping_modules->modules); $i<$n; $i++) {
$class = substr($shipping_modules->modules[$i], 0, strrpos($shipping_modules->modules[$i], '.'));
if(isset($GLOBALS[$class])) {
$retval[] = array(
'id' => $GLOBALS[$class]->code,
'text' => $GLOBALS[$class]->title
);
}
}
unset($shipping_modules, $class, $i, $n);
//-bof-a-lat9-illegal-string-offset
$order->delivery['country'] = $order->delivery['country']['name'];
//-eof-a-lat9-illegal-string-offset
}
return $retval;
}
Code:
function eo_get_order_by_id($oID) {
global $db, $order;
// Retrieve the order
$order = new order($oID);
// Add some required customer information for tax calculation
// The next method has been modified to add required info to the
// session and global variables.
zen_get_tax_locations();
// Cleanup tax_groups in the order (broken code in order.php)
// Shipping module will automatically add tax if needed.
$order->info['tax_groups'] = array();
foreach($order->products as $product) {
eo_get_product_taxes($product);
}
// Correctly add the running subtotal (broken code in order.php)
if(!array_key_exists('subtotal', $order->info)) {
$query = $db->Execute(
'SELECT value FROM `' . TABLE_ORDERS_TOTAL . '` ' .
'WHERE `orders_id` = \'' . (int)$oID . '\' ' .
'AND `class` = \'ot_subtotal\''
);
if(!$query->EOF) {
$order->info['subtotal'] = $query->fields['value'];
}
}
// Handle shipping costs (module will automatically handle tax)
if(!array_key_exists('shipping_cost', $order->info)) {
$query = $db->Execute(
'SELECT value FROM `' . TABLE_ORDERS_TOTAL . '` ' .
'WHERE `orders_id` = \'' . (int)$oID . '\' ' .
'AND `class` = \'ot_shipping\''
);
if(!$query->EOF) {
$order->info['shipping_cost'] = $query->fields['value'];
$_SESSION['shipping'] = array(
'title' => $order->info['shipping_method'],
'id' => $order->info['shipping_module_code'] . '_',
'cost' => $order->info['shipping_cost']
);
if(!isset($_SESSION['cart'])) {
require_once(DIR_FS_CATALOG . DIR_WS_CLASSES . 'shopping_cart.php');
$_SESSION['cart'] = new shoppingCart();
}
//-bof-a-lat9-illegal-string-offset
$country_info = $db->Execute('SELECT countries_id as id, countries_name as name, countries_iso_code_2 as iso_code_2, countries_iso_code_3 as iso_code_3 FROM ' . TABLE_COUNTRIES . " WHERE countries_name = '" . $order->delivery['country'] . "'");
$order->delivery['country'] = $country_info->fields;
//-eof-a-lat9-illegal-string-offset
// Load the shipping class into the globals
require_once(DIR_FS_CATALOG . DIR_WS_CLASSES . 'shipping.php');
$shipping_modules = new shipping($_SESSION['shipping']);
//-bof-a-lat9-illegal-string-offset
$order->delivery['country'] = $order->delivery['country']['name'];
//-eof-a-lat9-illegal-string-offset
}
}
return $order;
}
Re: Edit Orders v4.0 Support Thread
Quote:
Originally Posted by
Gadgit
Ok - I think I have come up with a solution to this now. I have done as I suggested and added an extra dimension to the front of the
id array which is the
$orders_products_id value.
For example - Line 903 in edit_orders.php
Code:
echo '<textarea class="attribsTextarea" name="id[' .$optionID[$j] . '][value]" rows="' . $optionInfo['rows'] .
'" cols="' . $optionInfo['size'] . '" id="attrib-' .
$optionID[$j] . '" >' . $text . '</textarea>' . "\n";
becomes
Code:
echo '<textarea class="attribsTextarea" name="id['.$orders_products_id.'][' . $optionID[$j] . '][value]" rows="' . $optionInfo['rows'] .
'" cols="' . $optionInfo['size'] . '" id="attrib-' .
$optionID[$j] . '" >' . $text . '</textarea>' . "\n";
and then, when this array is read from $_POST on line 276
Code:
zen_db_prepare_input($_POST['id']),
becomes
Code:
zen_db_prepare_input($_POST['id'][$orders_products_id]),
I have had a quick (but not thorough!) test of this, and it seems to work - can anyone see any reasons as to why this might cause problems elsewhere?
I now seem to have a problem in that the Sub-Total and hence, the Total never update, and they can't be modified manually, so the order totals cannot be changed, only by adding additional total lines (but then these get removed again upon updating the order). Is this expected functionality, have I missed something or is this a bug?
Cheers,
Scott
FWIW, a combination of the changes suggested in the referenced post plus the SQL update provided here (http://www.zen-cart.com/showthread.p...ag-not-working) allowed a client's upgraded site to be able too fully edit the attributes in an order.
Re: Edit Orders v4.0 Support Thread
Quote:
Originally Posted by
lat9
...
The two shipping modules that I've got enabled are (you guessed it), Free Shipping and USPS. The issue is that when the shipping modules are loaded under edit_orders, the global variable $order->delivery['country'] is a string containing the country's name. When the shipping modules are loaded from the store-front, $order->delivery['country'] is an array ...
Quote:
Originally Posted by
lat9
You may wish to join the BETA testing team (and would be most welcome). A number of bugs have been squashed, new enhancements added, and better interoperability with existing Zen Cart and 3rd party (shipping and order total) modules. Take a peek at the current list of changes (they are listed in the Edit Orders 4.1.1 readme).
Re: Edit Orders v4.0 Support Thread
Quote:
Originally Posted by
lhungil
You may wish to join the BETA testing team (and would be most welcome). A number of bugs have been squashed, new enhancements added, and better interoperability with existing Zen Cart and 3rd party (shipping and order total) modules. Take a peek at the current list of changes (they are listed in the Edit Orders 4.1.1 readme).
Thanks, lhungil, I'll give it a spin!
Re: Edit Orders v4.0 Support Thread
Zen v1.5.1
I just did a new installation of edit orders but I'm still having a problem with the sub-total being -0- when I change the quantity. I have made the changes recommended in the previous post but it hasn't fixed my problem.
I am running only the Tax Exempt plugin in addition to EO.
Also, my install file did not include anything for SQL, only the uninstall SQL.
Re: Edit Orders v4.0 Support Thread
Quote:
Originally Posted by
Shara
Also, my install file did not include anything for SQL, only the uninstall SQL.
Because as the readme indicates, the auto installer manages the SQL changes/execution..
Re: Edit Orders v4.0 Support Thread
How about the ability to edit "low order fee" for orders close to the limit?
Bill
Re: Edit Orders v4.0 Support Thread
Quote:
Originally Posted by
Angry Bill
How about the ability to edit "low order fee" for orders close to the limit?
Changing the behavior of an order total module in the admin sounds a little too much like bait and switch to me.
I strongly believe order total modules should act the same for both customers making an order online and when an admin adds / edits an order from the Zen Cart admin. This makes processing orders easier, ensures a seamless customer experience, and ensures anyone editing / adding an order does not "forget" rules imposed by order total modules.
I do understand a limited number of order total modules currently exist. But if one needs different functionality, one should create a new order total module (or modify the order total module) to fit their needs. New (or modified) order total modules should be posted to (or updated in) the plugin section. This would directly benefit the Zen Cart community in general and not just users of "Edit Orders".
Note: I see the potential need for an "Onetime Order Discount" order total module. This would provide an easy way to record and audit how many times an order is discounted. Using such an order total module would also ensure invoices, reports, and the customer's order history reflect the customer was given a one time order discount. If anyone else is interested or plans to build such a module... Feel free to send me a PM or email!
Re: Edit Orders v4.0 Support Thread
Quote:
Originally Posted by
lhungil
Changing the behavior of an order total module in the admin sounds a little too much like bait and switch to me.
lol ok. "bait and switch". I appreciate the effort put into this code A LOT and I use it quite a bit real time. I also equally find he responses here equally amusing :smile:. I will continue to use my Microsoft access back door to REALLY edit the orders as I need to edit them.
Re: Edit Orders v4.0 Support Thread
Quote:
Originally Posted by
lhungil
Changing the behavior of an order total module in the admin sounds a little too much like bait and switch to me.
I strongly believe order total modules should act the same for both customers making an order online and when an admin adds / edits an order from the Zen Cart admin. This makes processing orders easier, ensures a seamless customer experience, and ensures anyone editing / adding an order does not "forget" rules imposed by order total modules.
I do understand a limited number of order total modules currently exist. But if one needs different functionality, one should create a new order total module (or modify the order total module) to fit their needs. New (or modified) order total modules should be posted to (or updated in) the plugin section. This would directly benefit the Zen Cart community in general and not just users of "Edit Orders".
Note: I see the potential need for an "Onetime Order Discount" order total module. This would provide an easy way to record and audit how many times an order is discounted. Using such an order total module would also ensure invoices, reports, and the customer's order history reflect the customer was given a one time order discount. If anyone else is interested or plans to build such a module... Feel free to send me a PM or email!
I agree with the "bait and switch" characterization.. If an order total module has rules associated with it it would see more prudent to adjust the rules than the order total on the back end.. If the rules of say the "low order total" module aren't calculating as the shopowner thinks they should this is the RIGHT solution.. Anything else feels a tad.. ummm... dare I say "shady"...