I'm trying to create a module that lets me disable other shipping modes when free shipping is available.
I understand how to create a module and such, I can understand php relatively well I'm just lost as to how to filter this in regard to magento. I'm aware that you someone overwrite some existing rules within the module I'm making.
If someone could guide me as to how I do this within the xml file and the functions I need to use I'd be very grateful.
I've taken some steps into creating one myself after bits of googling.
<?xml version="1.0"?>
<config>
<modules>
<Shipping_Onepage_Method>
<version>1.0.0</version>
</Shipping_Onepage_Method>
</modules>
<blocks>
<checkout>
<rewrite>
<shipping_onepage_model_method>Shipping_Onepage_Model_Method</onepage_shipping_model_method>
</rewrite>
</checkout>
</blocks>
</config>
Then I've got located in /public_html/app/code/local/Markshust/Helloworld/model/available.php
I've got the following code which I'm led to believe will filter the shipping prices as I wish.
<?Php
class Shipping_Onepage_Model_Method 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;
}
}
?>
This doesn't seem to work, I've made amends on my xml file since made aware of the faults in the latest awnser.
Thanks