I have created a Magento module with an Observer that should hide a certain shipping method, but I can't get it to work.
class Company_Modulename_Model_Observer
{
public function hideShippingMethods(Varien_Event_Observer $observer)
{
if (Mage::getDesign()->getArea() === Mage_Core_Model_App_Area::AREA_FRONTEND) {
$quote = $observer->getEvent()->getQuote();
$store = Mage::app()->getStore($quote->getStoreId());
$carriers = Mage::getStoreConfig('carriers', $store);
$newPrice = 10;
foreach ($carriers as $carrierCode => $carrierConfig) {
if ($carrierCode == 'flatrate') {
$store->setConfig('carriers/flatrate/price', $newPrice);
$store->setConfig('carriers/flatrate/showmethod', '0');
$store->setConfig('carriers/flatrate/active', '0');
$store->setConfig('carriers/flatrate/title', 'Test title');
}
}
}
}
}
Of all the setConfig settings only the $store->setConfig('carriers/flatrate/title', 'Test title'); works.
So the title of the delivery method gets changed in the checkout, but the price doesn't change and it is still shown.
How can I hide or change the price of a certain shippig method?