-
Mage_Checkout_Block_Onepage_Shipping_Method_Available::getShippingRates()
-
1.重写块类
文件: app/code/local/MagePsycho/Shipmentfilter/etc/config.xml:
entfilter/etc/config.xml:
代码:
-
…
-
<blocks>
-
…
-
<checkout>
-
<rewrite>
-
<onepage_shipping_method_available>MagePsycho_Shipmentfilter_Block_Onepage_Shipping_Method_Available</onepage_shipping_method_available>
-
</rewrite>
-
</checkout>
-
…
2.重写 getShippingRates() 方法
文件: app/code/local/MagePsycho/Shipmentfilter/Block/Onepage/Shipping/Method/Available.php
代码:
-
<?php
-
/**
-
* @category MagePsycho
-
* @package MagePsycho_Shipmentfilter
-
* @author magepsycho@gmail.com
-
* @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.刷新缓存。