I'm using CE 1.9.0.1 and have correctly created and registered my module, but I can't seem to detect the shipping methods. Basically, I want to hide Cash on Delivery if Flat Rate or Free Shipping is chosen. Here is the code I have for my observer class:
class Kol_PaymentToggle_Model_Observer
{
public function paymentMethodIsActive(Varien_Event_Observer $observer) {
$event = $observer->getEvent();
$method = $event->getMethodInstance();
$result = $event->getResult();
$quote = $observer->getEvent()->getQuote();
$shippingMethod = $quote->getShippingAddress()->getShippingMethod();
if($shippingMethod == "standardshipping" || $shippingMethod == "free") {
if($method->getCode() == 'cashondelivery' ) {
$result->isAvailable = false;
}
}
}
}
I'm guessing that I haven't used the correct shipping method code names or payment method code names, but I'm unsure. Anyone has any advice?
EDIT: I only have 3 shipping methods enabled:
- Collect In Store
Title = Collect in Store
Method Name = Collect In Store (Extension link) - Flat Rate
Title = Standard Delivery
Method Name = Standard Shipping - Free Shipping
Title = Free Delivery
Method Name = Free
Hopefully this extra information can prove useful towards helping me!