Hide other shipping methods when FREE shipping is enabled

When free shipping method is enabled, it is shown along with other available shipping methods unlike free payment method ‘Zero Subtotal Checkout’.
There is no harm in showing other payment methods along with the free shipping method. Nevertheless, some merchants want to hide the rest of the methods when it is enabled.

There are many ways to do it. One of the way is to override the method:


1. Rewrite the block class

File: app/code/local/MagePsycho/Shipmentfilter/etc/config.xml:


2. Override the getShippingRates() method

File: app/code/local/MagePsycho/Shipmentfilter/Block/Onepage/Shipping/Method/Available.php:

 * @category   MagePsycho
 * @package    MagePsycho_Shipmentfilter
 * @author     [email protected]
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
class MagePsycho_Shipmentfilter_Block_Onepage_Shipping_Method_Available extends Mage_Checkout_Block_Onepage_Shipping_Method_Available
	public function getShippingRates()
		$rates = parent::getShippingRates();
		if (array_key_exists('freeshipping', $rates)) {
			$rates = array('freeshipping' => $rates['freeshipping']);

		return $rates;

3. Refresh the cache. Bingo!