4

How can I remove a specific payment option when a specific shipping method is checked?

Below is a screenshot explanation:

Screenshot explanation

5

There is a function on the payment abstract that checks if a method can be used based on the quote. Mage_Payment_Model_Method_Abstract::isApplicableToQuote if this only is applicable to the pay on delivery method then simply rewrite the payment method Mage_Payment_Model_Method_Cashondelivery and add your own isApplicableToQuote. Here you can check on the quote object what shipping method has been selected and return if the payment method can be used.

public function isApplicableToQuote($quote, $checksBitMask)
{
    if (Check if shipping method is X) {
        return false;
    }
    return parent::isApplicableToQuote($quote, $checksBitMask);
}
0

Just in case you don't want to create a new payment_method you can use de event payment_method_is_active thrown in Mage_Payment_Model_Method_Abstract::isAvailable. In the Observer you will see that the event is fired once for every payment_method of your Magento and if you want to disable one of them you should do this in your Observer class

public function disallowPaymentMethod($observer) {
    if ($observer['method_instance']->getCode() == 'desired_payment_method_code') {
        $observer['result']['isAvailable'] = null;
    }
}

And that's it!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.