Results 1 to 9 of 9
  1. #1
    Join Date
    Jul 2005
    Location
    Orlando, Fl
    Posts
    324
    Plugin Contributions
    0

    Default 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

  2. #2
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

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

  3. #3
    Join Date
    Jul 2005
    Location
    Orlando, Fl
    Posts
    324
    Plugin Contributions
    0

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

    1.3.8a

  4. #4
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default 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)
    Code:
        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:
    Code:
          usort($methods,'ups_sort_by_price'); // sort methods by price
          $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.

  5. #5
    Join Date
    Jul 2005
    Location
    Orlando, Fl
    Posts
    324
    Plugin Contributions
    0

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

    Thanks Dr B !!

  6. #6
    Join Date
    Apr 2010
    Posts
    265
    Plugin Contributions
    1

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

    Is this code change the same for 1.5.0?

  7. #7
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

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

  8. #8
    Join Date
    Apr 2010
    Posts
    265
    Plugin Contributions
    1

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

    Works perfectly. Thank you.

  9. #9
    Join Date
    Apr 2007
    Location
    Dayton, Ohio
    Posts
    672
    Plugin Contributions
    0

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

    Quote Originally Posted by DrByte View Post
    2. Find (around line 185 or so) this line, and add the line shown in red above it:
    Code:
          usort($methods,'ups_sort_by_price'); // sort methods by price
          $this->quotes['methods'] = $methods;
    In the UPS version ups_v2015-12-30 it's line number 204. Works like a charm!

 

 

Similar Threads

  1. UPS-XML config prob. - shipping methods aren't showing up
    By lunule in forum Addon Shipping Modules
    Replies: 0
    Last Post: 27 Apr 2010, 12:00 AM
  2. Subtracting UPS Ground cost from other UPS methods
    By sabucat in forum Built-in Shipping and Payment Modules
    Replies: 3
    Last Post: 14 May 2009, 05:08 AM
  3. Shipping Estimator Sort Shipping Methods
    By sitehatchery in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 15 Apr 2007, 05:34 AM
  4. Free Shipping for Priority Mail, but UPS methods extra
    By techmon in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 9 Nov 2006, 06:55 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR