Jump to content



Photo
- - - - -

How to Re-Order USPS Shipping Options by Cost?


  • Please log in to reply
9 replies to this topic

#1   krdito

krdito
  • Members
  • 92 posts
  • Real Name:Krdito
  • Gender:Female

Posted 24 January 2012 - 23:29

We offer three USPS shipping options: Express Mail, Priority Mail, and Parcel Post.

During checkout, our customers are shown these 3 options in order of price, highest to lowest. We would like to reverse the order so that the most economical method is shown first.

I have searched and searched with the USPS shipping module, but can't figure out how to change to order to show the shipping methods from lowest to highest cost.

Can anyone help?

Many thanks!!

#2   krdito

krdito
  • Members
  • 92 posts
  • Real Name:Krdito
  • Gender:Female

Posted 27 January 2012 - 15:37

Looks like "Added sorting of USPS rates from least to most expensive" was part of USPS Methods Version 3.0.2.

I am using Version 6.0 and don't see an option to change the USPS sort order (mine is shown from most to least expensive).

Any help is greatly appreciated!

#3   devoidofodors

devoidofodors
  • Members
  • 17 posts
  • Real Name:Steven
  • Gender:Male
  • Location:Portland

Posted 16 February 2012 - 06:47

It's a simple programming task you learn when you're first starting out. I'm tired of programming today, but I'll help you get there:

Put this piece of code in the file that displays the shipping options (we use a custom checkout_payment.php page and it displays the shipping rates) to see the array delivered from the USPS: " <?php print_r($quotes) ?> "
Then use a little bit of php code to resort the array based on prices before they're printed on the screen (look for a for look in the code).
Check this page out: http://php.net/manua...ray.sorting.php

Maybe in a couple of days or so, I'll get around to it. I had the same thought today, oddly enough. SWED.

#4   devoidofodors

devoidofodors
  • Members
  • 17 posts
  • Real Name:Steven
  • Gender:Male
  • Location:Portland

Posted 16 February 2012 - 07:10

that php code is only temporary, just enough to give you a visual of what's actually going on.

#5   krdito

krdito
  • Members
  • 92 posts
  • Real Name:Krdito
  • Gender:Female

Posted 16 February 2012 - 13:15

Thank you so much for your reply! We should be able to figure it out now /thumbsup.gif' class='bbc_emoticon' alt=':thumbsup:' />

#6   Avec

Avec
  • Members
  • 834 posts
  • Real Name:Jeffrey Todd
  • Gender:Male

Posted 17 February 2012 - 02:32

$quotes on checkout_shipping is a combination of a couple of arrays, including methods and rates. In USPS shipping methods 6.0 there is actually code that states "to sort highest to lowest" and uses the arsort function. I attempted to reverse this by simply changing it to rsort, but it changed nothing.

#7   krdito

krdito
  • Members
  • 92 posts
  • Real Name:Krdito
  • Gender:Female

Posted 17 February 2012 - 15:55

Avec is my husband, who is kindly working on this for me : )

#8   krdito

krdito
  • Members
  • 92 posts
  • Real Name:Krdito
  • Gender:Female

Posted 26 April 2012 - 17:28

We have not been able to figure this out, although my husband Avec has a lot of php experience. Anyone able to give us a bit more guidance to get this accomplished?

Many thanks!

#9   a.forever

a.forever
  • Members
  • 236 posts
  • Real Name:Kevin
  • Gender:Male

Posted 02 May 2012 - 17:52

$quotes on checkout_shipping is a combination of a couple of arrays, including methods and rates. In USPS shipping methods 6.0 there is actually code that states "to sort highest to lowest" and uses the arsort function. I attempted to reverse this by simply changing it to rsort, but it changed nothing.

We have not been able to figure this out, although my husband Avec has a lot of php experience. Anyone able to give us a bit more guidance to get this accomplished?

Many thanks!


I would suggest switching over to this USPS contribution:

osCommerce v2.2 - http://addons.oscommerce.com/info/8403
osCommerce v2.3.1 - http://addons.oscommerce.com/info/8327

Otherwise, I think the opposite of the arsort function is asort, not rsort.

#10   krdito

krdito
  • Members
  • 92 posts
  • Real Name:Krdito
  • Gender:Female

Posted 03 May 2012 - 18:20

a.forever -THANK YOU! I knew it has to be something stupid...changed to "asort" and the shipping prices are now shown from lowest to highest.

Now off to figure out how to make Priority Mail the default, even if it is not the cheapest : )