Hi,
When developing a new shipping module for Zen Cart I found a bug in the file:
includes/modules/pages/checkout_shipping/header_php.php
Although Zen Cart allows the usage of several shipping methods by each shipping module, it would appear that no-one has ever used this functionality as, when submitting the checkout shipping page, the customer's selection is ignored and the first shipping method for the selected shipping module is always chosen!
It's a very simple bug to fix and I'm happy to include a diff patch for it below...
I'd appreciate it if this could be updated in the next version of ZC so that I don't have to have instructions in our new shipping module on how to modify this core file!![]()
The patch for this is as follows, please e-mail me if you want a copy of a freshly updated ZC1.3.7 file:
Hope you find this helpful!PHP Code:@@ -144,16 +144,26 @@
} else {
$quote = $shipping_modules->quote($method, $module);
}
if (isset($quote['error'])) {
$_SESSION['shipping'] = '';
} else {
- if ( (isset($quote[0]['methods'][0]['title'])) && (isset($quote[0]['methods'][0]['cost'])) ) {
+ // Identify the shipping method selected by the user (some shipping modules can have
+ // several methods/ways in their quote).
+ $shipping_method_index = 0;
+ $num_shipping_methods = sizeof($quote[0]['methods']);
+ for ($i = 0; $i < $num_shipping_methods; $i++) {
+ if (($module . '_' . $quote[0]['methods'][$i]['id']) == $_SESSION['shipping']) {
+ $shipping_method_index = $i;
+ break;
+ }
+ }
+ if ( (isset($quote[0]['methods'][$shipping_method_index]['title'])) && (isset($quote[0]['methods'][$shipping_method_index]['cost'])) ) {
$_SESSION['shipping'] = array('id' => $_SESSION['shipping'],
- 'title' => (($free_shipping == true) ? $quote[0]['methods'][0]['title'] : $quote[0]['module'] . ' (' . $quote[0]['methods'][0]['title'] . ')'),
- 'cost' => $quote[0]['methods'][0]['cost']);
+ 'title' => (($free_shipping == true) ? $quote[0]['methods'][$shipping_method_index]['title'] : $quote[0]['module'] . ' (' . $quote[0]['methods'][$shipping_method_index]['title'] . ')'),
+ 'cost' => $quote[0]['methods'][$shipping_method_index]['cost']);
zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
}
}
} else {
$_SESSION['shipping'] = false;
All the best...
Conor
ceon




