Right now the FedEx, Flat right, UPS and USPS modules output the shipping options in alphabetical order. so "2 day" shipping is at the top and "ground" is in the middle. I really think this should be sorted by price because most consumers are familiar with it being ordered that way. Always have the least expensive option on top so that it defaults to what the user is most likely going to want - because right now the default is "2 day" which is my most expensive option of shipping.
It would also be nice to order or set the weights of all shipping options so I can say I want my "free shipping" flat rate on the top (and default) and then have FedEx next, then UPS. or intermingle FedEx and UPS so they gradually increase in price and expedition.
Is there a way to do this?
Comments
Comment #1
deggertsen commentedIt appears this may have been fixed at one time? #1324646: Sort shipping-rules by weight
However, I can't find where to set the weights, so maybe it's broken again.
Comment #2
davidwhthomas commentedPerhaps it's because the rules are now components, which don't have a weight property per se.
I found there's a hook you can use to alter the commerce shipping option ordering.
hook_commerce_shipping_service_rate_options_alter
For example, I prefixed the machine name of the shipping rule with a number
e.g
001_courier_1
004_courier_2
008_courier_3
And then did a sort on those with this code:
HTH,
Cheers,
DT
Comment #3
googletorp commentedComment #4
deggertsen commentedWhy would this be fixed? It seems to me that at least the code portion of #2 should actually be committed to Commerce Shipping instead of it being in a custom module. I might be willing to create a patch if necessary, but it seems like it would be simple to add natsort($options); to the shipping rate options as the default, then if people wanted to override it they could.
Comment #5
davidwhthomas commentedI was thinking a code patch that added a menu tab to the shipping config area for sorting shipping options would be nice.
Ideally a drag/drop table as per other core sorting interfaces.
Save the form to set a $conf variable with the weight ordering.
Apply that weight in hook_commerce_shipping_service_rate_options_alter
That would do it.
Comment #6
mrpeanut commentedSorting by price can be done with this code (from #1537394-22: Change Shipping Services Row Weights):
However, it would be nice to have weights for more control.
Comment #7
googletorp commentedComment #8
deggertsen commentedPlease don't mark as fixed without comment or justification. As of right now it appears that this needs to be changed to a feature request to add weights to the shipping options. It appears that there is already a weight option for fixed Flat Rate Shipping (see #1537394: Change Shipping Services Row Weights, but not for all shipping options in general. I believe that is the request here.
Comment #9
googletorp commentedGiven the lack of interest in this (no comments in 2 years) I'm closing this (won't fix).
If any one want to see this happen and actually want to work on this (have a patch) they are most welcome to reopen. I'll be happy to review the patch, but won't actually want to develop this myself.