Contributions

Shipping Modules (Category Index)
Search: 

Default Selected Shipping Method

Choose the shipping method default selected in the checkout_shipping.php page in the shop; not necessarily the cheapest.

Expand All / Collapse All

Update when multiple prices exist in selected module v1.0.1 19 Dec 2006

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...

Default Selected Shipping Method Update 15 Dec 2006
Default Selected Shipping Method 18 Jul 2006

Note: Contributions are used at own risk.