
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;
}
Bookmarks