You will have to write some code. If you use the notifier 'NOTIFY_SHIPPING_MODULE_CALCULATE_CHEAPEST' you can set the cheapest to anything you want.
I wrote one to exclude surface mail from being selected as the cheapest.
includes/classes/observers/cheapest_mail_recalculate.php
Code:
<?php
// -----
// An observer-class to enable recalculation of the minimum postage to exclude options.
//
//
class CheapestMailRecalculate extends base {
public function __construct() {
$this->attach($this, array(
'NOTIFY_SHIPPING_MODULE_CALCULATE_CHEAPEST'
));
}
public function update(&$class, $eventID, $cheapestIn, &$cheapestOut, $rates) {
/*
* only need to change if royalmail surface (economy) rmsm or book surface bksm
*/
if (substr($cheapestIn['module'], 0, 4) == 'rmsm' or substr($cheapestIn['module'], 0, 4) == 'bksm') {
$cheapestOut = false;
$size = sizeof($rates);
for ($i = 0; $i < $size; $i++) {
if (is_array($cheapestOut)) {
/*
* already found rate is this one cheaper
*/
if ($rates[$i]['cost'] < $cheapestOut['cost'] and $rates[$i]['module'] != 'storepickup' and substr($rates[$i]['module'], 0, 4) != 'rmsm' and substr($rates[$i]['module'], 0, 4) != 'bksm') {
$cheapestOut = $rates[$i];
}
} else {
/*
* not found a rate yet set if not storepickup or economy
*/
if ($rates[$i]['module'] != 'storepickup' and substr($rates[$i]['module'], 0, 4) != 'rmsm' and substr($rates[$i]['module'], 0, 4) != 'bksm') {
$cheapestOut = $rates[$i];
}
}
}
}
}
}
includes/auto_loadres/config.cheapest_mail_recalculate.php
Code:
<?php
$autoLoadConfig[10][] = array('autoType'=>'class',
'loadFile'=>'observers/cheapest_mail_recalculate.php');
$autoLoadConfig[90][] = array('autoType'=>'classInstantiate',
'className'=>'CheapestMailRecalculate',
'objectName'=>'CheapestMailRecalculate');
This was written some time ago for 1.3.7 zen cart there are other ways of writing observers now.
see https://docs.zen-cart.com/dev/code/notifiers/.
Bookmarks