Community Add-Ons
| Maintainers: | JeanLuc |
Default Selected Shipping Method
for osCommerce Online Merchant v2.2
Choose the shipping method default selected in the checkout_shipping.php page in the shop; not necessarily the cheapest.
I modded this so that if you set a shipping module default that has more than one price it will select the cheapest price WITHIN that module choice.
So for example if you have 3 modules for shipping installed, fedex, ups, customer pickup, and you set the default to ups let say. With this addition instead of picking the last option in ups (IE usually NExt day air) it will select the cheapest method within the shipping module which is chosen in the admin page, which in most cases for UPS for example would be UPS Ground.
The change is within catalog/includes/classes/shipping.php:
instead of the previous add use this for the change to shipping.php:
-------
Add
// BOF DEFAULT_SHIPPING_METHOD
function shipping_default($title) {
if (is_array($this->modules)) {
$monModule = array();
reset($this->modules);
while (list(, $value) = each($this->modules)) {
$class = substr($value, 0, strrpos($value, '.'));
if ($class == $title) {
if ($GLOBALS[$class]->enabled) {
$quotes = $GLOBALS[$class]->quotes;
$monModule_cost = "";
for ($i=0, $n=sizeof($quotes['methods']); $i<$n; $i++) {
$monModule[] = array('id' => $quotes['id'] . '_' . $quotes['methods'][$i]['id'],
'title' => $quotes['module'] . ' (' . $quotes['methods'][$i]['title'] . ')',
'cost' => $quotes['methods'][$i]['cost']);
if (($monModule[$i]['cost'] < $monModule_cost ) || ($monModule_cost == '')) {
$monModule_cost = $monModule[$i]['cost'];
$shipping_default = $monModule[$i];
}
}
}
}
}
return $shipping_default;
}
}
// EOF DEFAULT_SHIPPING_METHOD
-----------------
This is a full package I have updated...
