-
FedEx sort order?
Is it possible to apply a price sort order to the built in FedEx shipping module? I mean display FedEx prices from the lowest available price (show first) to highest available price (show last)? With the lowest price automatically selected?
Most would want the lowest price, so this option would make it easier since we offer many FedEx shipping options available.
-
Re: FedEx sort order?
You could adapt the code to use something from the USPS RateV4 shipping module ...
Edit the file:
/includes/modules/shipping/fedexwebservices.php
and add the code in RED:
Code:
// bof: adapted functions contributed by Marco B
//Quote sorting functions
if (!function_exists('fedex_sort_Alphanumeric')) {
function fedex_sort_Alphanumeric ($a, $b) {
return strcmp($a['title'],$b['title']);
}
}
if (!function_exists('fedex_sort_Price')) {
function fedex_sort_Price ($a, $b) {
$c=(float)$a['cost'];
$d=(float)$b['cost'];
if ($c==$d) return 0;
return ($c>$d?1:-1);
}
}
// eof: adapted functions contributed by Marco B
class fedexwebservices {
Code:
$methods[] = array('id' => str_replace('_', '', $rateReply->ServiceType),
'title' => ucwords(strtolower(str_replace('_', ' ', $rateReply->ServiceType))),
'cost' => $cost + (strpos($this->handling_fee, '%') ? ($cost * (float)$this->handling_fee / 100) : (float)$this->handling_fee));
// bof: adapted sort by contributed by Marco B
// Sort the options
define('MODULE_SHIPPING_FEDEX_QUOTE_SORT', 'Price');
//define('MODULE_SHIPPING_FEDEX_QUOTE_SORT', 'Alphanumeric');
if (MODULE_SHIPPING_FEDEX_QUOTE_SORT != 'Unsorted') {
usort($methods,'fedex_sort_'.MODULE_SHIPPING_FEDEX_QUOTE_SORT);
}
// eof: adapted sort by contributed by Marco B
and that should sort the Prices from Low to High ...
-
Re: FedEx sort order?
Works perfectly. Thank you so much!!
-
Re: FedEx sort order?
You are most welcome ... thanks for the update that this worked for you ... :smile: