Hi all,
I'm running zen cart 1.3.8a, and protx module 3.4.1 (according to its source).
Just wondered if this sounds sensible. I've searched the forum but can't see anything obviously related. I'm not familiar with why includes/classes/order.php is different to admin/includes/classes/order.php.
I'm supporting a site that, until the other day, has never needed any real geo zone setup. There was a single UK zone defined, but the single payment module, protx, was set to not bother with it ("Payment Zone"="None").
Having defined an EU payment zone and told protx to use the UK zone only, I am finding I cannot view orders using the admin interface. This seems to boil down to a difference between includes/classes/order.php and admin/includes/classes/order.php, the way they fill in $this->billing['country'].
When a customer places an order, the $order object has its 'cart' method called, which fills in $this->billing['country'] like this:
PHP Code:
$this->delivery = array('firstname' => $shipping_address->fields['entry_firstname'],
[cut]
'country' => array('id' => $shipping_address->fields['countries_id'], 'title' => $shipping_address->fields['countries_name'], 'iso_code_2' => $shipping_address->fields['countries_iso_code_2'], 'iso_code_3' => $shipping_address->fields['countries_iso_code_3']),
When the admin page wants to view an order, it calls the $order method 'query', which does this:
PHP Code:
$this->delivery = array('name' => $order->fields['delivery_name'],
[cut]
'country' => $order->fields['delivery_country'],
The protx module has an update_status method, only called when the protx module is configured to use a zone, that has an SQL statement like this:
PHP Code:
$sql = "
SELECT
zone_id
FROM
" . TABLE_ZONES_TO_GEO_ZONES . "
WHERE
geo_zone_id = " . $this->zone . "
AND
zone_country_id = " . $order->billing['country']['id'] . "
ORDER BY
zone_id
";
When the admin page tries to retrieve an order, the use of $order->billing['country']['id'] in the protx module results in the value "U" when the $order->billing['country'] field is "United Kingdom" (fetched from the 'orders' table). This leads to an SQL error such as:
Code:
1054 Unknown column 'U' in 'where clause'
in:
[ SELECT zone_id FROM zen_zones_to_geo_zones WHERE geo_zone_id = 2 AND zone_country_id = U ORDER BY zone_id ]
So there seem to be two options.
1/ Would you advise I leave the two order.php classes alone, despite their differences, and fix the protx code to handle the two possible values of $order->billing['country']? i.e. assume this is a bug in the protx module.
2/ Or, should I 'fix' one of the order.php classes so $order->billing['country'] is defined the same by each, and deal with the likely chaos that would ensue throughout the rest of the zen cart codebase?
Inherent in these questions is the question of whether the 'client' code (includes/classes) is really supposed to be generating different data structures to the 'admin' code (admin/includes/classes).
Thanks :)
Nick
Bookmarks