Forums / Built-in Shipping and Payment Modules / Can I sort UPS shipping methods from least to greatest?

Can I sort UPS shipping methods from least to greatest?

Views: 1,780

Results 1 to 9 of 9
28 Jun 2013, 8:12 PM
#1
djdavedawson avatar

djdavedawson

Zen Follower

Join Date:
Jul 2005
Location:
Orlando, Fl
Posts:
343
Plugin Contributions:
0

Can I sort UPS shipping methods from least to greatest?

I'm using the UPS shipping module and it sorts the shipping rates from greatest to least.

Is there a way to reverse this?

Thanks in Advance

~D

28 Jun 2013, 8:52 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Can I sort UPS shipping methods from least to greatest?

What version of Zen Cart?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

28 Jun 2013, 9:04 PM
#3
djdavedawson avatar

djdavedawson

Zen Follower

Join Date:
Jul 2005
Location:
Orlando, Fl
Posts:
343
Plugin Contributions:
0

Re: Can I sort UPS shipping methods from least to greatest?

1.3.8a :(

28 Jun 2013, 9:23 PM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Can I sort UPS shipping methods from least to greatest?

Two edits to /includes/modules/shipping/ups.php:

  1. Add this to the very bottom of the file (If the file ends with a ?>, then remove the ?> altogether and put this at the bottom) ```
    function ups_sort_by_price($a, $b) {
    $c=(float)$a['cost'];
    $d=(float)$b['cost'];
    if ($c==$d) return 0;
    return ($c>$d?1:-1);
    }

2. Find (around line 185 or so) this line, and add the line shown in red above it:```
      [B]usort($methods,'ups_sort_by_price'); // sort methods by price[/B]
      $this->quotes['methods'] = $methods;

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

28 Jun 2013, 9:31 PM
#5
djdavedawson avatar

djdavedawson

Zen Follower

Join Date:
Jul 2005
Location:
Orlando, Fl
Posts:
343
Plugin Contributions:
0

Re: Can I sort UPS shipping methods from least to greatest?

Thanks Dr B !!

31 Jul 2013, 6:56 PM
#6
vanhorn_s avatar

vanhorn_s

Zen Follower

Join Date:
Apr 2010
Posts:
283
Plugin Contributions:
0

Re: Can I sort UPS shipping methods from least to greatest?

Is this code change the same for 1.5.0?

31 Jul 2013, 9:19 PM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Can I sort UPS shipping methods from least to greatest?

Probably.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

1 Aug 2013, 1:18 AM
#8
vanhorn_s avatar

vanhorn_s

Zen Follower

Join Date:
Apr 2010
Posts:
283
Plugin Contributions:
0

Re: Can I sort UPS shipping methods from least to greatest?

Works perfectly. Thank you.

19 Jan 2016, 9:02 PM
#9
sports_guy avatar

sports_guy

Totally Zenned

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

Re: Can I sort UPS shipping methods from least to greatest?

DrByte:

  1. Find (around line 185 or so) this line, and add the line shown in red above it:```
    [B]usort($methods,'ups_sort_by_price'); // sort methods by price[/B]
    $this->quotes['methods'] = $methods;

In the UPS version ups_v2015-12-30 it's line number 204. Works like a charm!

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