Forums / Addon Payment Modules / FedEx sort order?

FedEx sort order?

Views: 2,093

Results 1 to 4 of 4
9 Apr 2012, 11:56 PM
#1
sports_guy avatar

sports_guy

Totally Zenned

Join Date:
Apr 2007
Location:
Dayton, Ohio
Posts:
682
Plugin Contributions:
0

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.

Building a better web, one site at a time: Dayton Web Design

10 Apr 2012, 5:43 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

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:

// 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 {
          $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 ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

12 Apr 2012, 12:15 AM
#3
sports_guy avatar

sports_guy

Totally Zenned

Join Date:
Apr 2007
Location:
Dayton, Ohio
Posts:
682
Plugin Contributions:
0

Re: FedEx sort order?

Works perfectly. Thank you so much!!

Building a better web, one site at a time: Dayton Web Design

12 Apr 2012, 1:51 AM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: FedEx sort order?

You are most welcome ... thanks for the update that this worked for you ... :smile:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!