Remove Flat Rate Shipping Option if Free Rate is showing in Magento

-->

At your magento home directory,
app/design/frontend/blank/default/template/checkout/onepage/shipping_method/available.phtml
<?php if (!($_shippingRateGroups = $this->getShippingRates())): ?>
<p><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></p>
<?php else: ?>
<dl>
<?php $freeShippingMethodFlag = false; ?>
<?php foreach ($_shippingRateGroups as $code => $_rates): ?>

<?php if (!$freeShippingMethodFlag): ?>
<dt><?php echo $this->getCarrierName($code) ?></dt>
<dd>
<ul>
<?php foreach ($_rates as $_rate): ?>
<li>
<?php if ($_rate->getErrorMessage()): ?>
<ul><li><ul><li><?php echo $_rate->getErrorMessage() ?></li></ul></li></ul>
<?php else: ?>
<input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"' ?> />
<label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?>
<?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
<?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
<?php echo $_excl; ?>
<?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
(<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
<?php endif; ?>
</label>
<?php endif ?>
</li>
<?php endforeach; ?>
</ul>
</dd>
<?php endif; ?>
<?php if($code == 'freeshipping') { $freeShippingMethodFlag = true;}?>
<?php endforeach; ?>
</dl>
<?php endif; ?>

One response to “Remove Flat Rate Shipping Option if Free Rate is showing in Magento”

  1. hisham says:

    Hello

    How to automatically checked the radioo button for free shipping similar to flat rate shipping ?