Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
I was in a situation where the name of the shipping method contained the number at the end with all other naming exactly the same, so if it was shipping_method_9 and shipping_method_10 then shipping_method_10 is sorted before shipping_method_9 so I am updating the js to sort the shipping methods by rate. Will attach code once issue is created
Comment | File | Size | Author |
---|---|---|---|
#4 | ubercart_1198294_sort_order_by_rate_cleanedup.patch | 2.14 KB | robbiethegeek |
#1 | ubercart_1198294_sort_order_by_rate.patch | 899 bytes | robbiethegeek |
Comments
Comment #1
robbiethegeek CreditAttribution: robbiethegeek commentedpatch code
Comment #2
longwaveComment #3
longwavehttp://drupal.org/project/uc_checkout_tweaks can do this but it could be useful to merge that into Ubercart core.
Comment #4
robbiethegeek CreditAttribution: robbiethegeek commentedHere is better logic and actually working code :)
Comment #5
robbiethegeek CreditAttribution: robbiethegeek commentedIf nothing else this seems like a much more sensible default.
Comment #6
longwaveWouldn't it be easier to sort them server-side?
Comment #7
TR CreditAttribution: TR commentedThe shipping methods that use an external API, i.e. UPS, USPS, FedEx, Canada Post, already return rates sorted by price. If you have all these methods enabled, you will see them grouped by carrier then sorted from low price to high price within that carrier. I think this is how is should be - I think it would be bad to interleave UPS, USPS, and FedEx quotes, for instance.
The OP's issue seems to be that the flatrate and weightquote methods *don't* have this sorting, so if for example you have several flatrates they will not necessarily appear sorted by price. I think that sorting should be added to uc_flatrate and uc_weightquote - it should *not* be done in uc_quote as that would result in the interleaving I mentioned above. And as #6 said, this should not be done in JavaScript either, it should be done on the server side just as it's done by uc_ups and uc_usps in core.
Comment #8
TR CreditAttribution: TR commentedWrong status.
EDIT: Actually, now that I think about it, you can't sort in uc_flatrate or uc_weightquote because these don't return multiple quotes like for example uc_usps does. Each user-defined flatrate or weightquote returns one and only one number. Because of this, I think the way to sort would be to assign the desired "list position" to each user-defined method. This can be done through the Ubercart user interface (admin/store/settings/quotes/methods/edit), so I don't see that any change is needed here.
Comment #10
longwave#1091768: Arrange shipping methods requested ordering them another way, so perhaps this needs to be a configuration option.
Comment #11
TR CreditAttribution: TR commentedActually, I think #1091768: Arrange shipping methods is essentially the same as #624692: Improve theme-ability of shipping quotes EVEN MORE and can be handled in that issue.
The only issue left for consideration is whether we should enable intermingling of quotes from different carriers when sorting by rate. I personally don't think so, but if someone feels strongly enough about this to write a patch that works for 7.x-3.x, passes the test cases, adds an admin option for this new sort order to make it optional (and off by default to be backwards compatible), and deals properly with the changes proposed in #624692: Improve theme-ability of shipping quotes EVEN MORE (which I *do* think should be added), then we can put this into Ubercart. New features like this should go into 7.x-3.x first.
Comment #12
SilviuChingaru CreditAttribution: SilviuChingaru commentedComment #13
TR CreditAttribution: TR commented@fiftyz - you assigned this to yourself, is this something you're working on?
Comment #14
SilviuChingaru CreditAttribution: SilviuChingaru commentedComment #15
TR CreditAttribution: TR commentedThree years later, my opinion from #11 hasn't changed and no one seems to want this, so I'm closing it.