Right now the FedEx module outputs 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 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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mglaman’s picture

I started to look into this. I was able to successfully sort the array response using the following code in commerce_fedex_service_rate_order right before the return value.

<?php
$amounts = array();
		foreach($rates as $rate) {
			$amounts[] = $rate['amount'];
		}
		array_multisort($amounts, SORT_ASC, $rates);
?>
mglaman’s picture

Here is a patch I made for the module. It uses explode() to get the shipping rate prices and does an array_multisort() to get prices listed in ascending order.

iwant2fly’s picture

I would also be very interested in this ability, as well as maybe a way to change the name of the service offering. Having it say [FedEXLOGO] FedEx 2 Day is redundant.

iwant2fly’s picture

Would this be better to report/request in the Commerce_Shipping Module, so that it sorts all available shipping options by price rather than just the FedEx ones?

mesch’s picture

See http://drupal.org/node/1537394#comment-7399800 for a possible solution to sorting all shipping services by price.

mglaman’s picture

Issue summary: View changes
Status: Active » Needs review

@MEsch this is true, but it my opinion a shipping service should be by rate on its own, then individual module to shuffle all together.

Also realized this was never marked for review.

kevinsiji’s picture

The patch at #2 did not worked until I changed the explode to $shipping_rate_cost = explode(': $', $shipping_rate);

prophet108’s picture

Can we get this worked into the next commit?

andyg5000’s picture

Category: Bug report » Feature request
Priority: Major » Normal
Status: Needs review » Closed (won't fix)

Typically I handle this with @mglaman's sort routine that affects all shipping methods (including non FedEx).

http://glamanate.com/blog/sort-drupal-commerce-shipping-services

I think this should actually be added as an option in commere_shipping. If more people think that this should be set at the per-provider level, I'm happy to revisit, but either way this is not a critical bug.