0

I wrote an observer that filters payments based on another post from here. This works fine for Magento's default payment methods but not for the methods in Buckaroo and this is because Buckaroo has it's own isActive / isAvailable functions. Now i'm trying to do a rewrite but i can't get it too work. Anyone can see what i'm doing wrong? Here comes my code:

Module.xml

<codePool>local</codePool>
            <depends>
                <TIG_Buckaroo3Extended/>
                <Idev_OneStepCheckout/>
                <Mage_Sales/>
                <Mage_Payment />
            </depends>

config.xml

<models>
    <buckaroo3extended>
                <rewrite>
                    <paymentMethods_paymentMethod>Mycompany_PaymentRestriction_Model_PaymentMethods_PaymentMethod</paymentMethods_paymentMethod>
                </rewrite>
            </buckaroo3extended>
        </models>

PaymentMethod.php

class Mycompany_PaymentRestriction_Model_PaymentMethods_PaymentMethod extends TIG_Buckaroo3Extended_Model_PaymentMethods_PaymentMethod {

    public function isAvailable($quote = null) {

        Mage::log('rewrite active');
        return false;
    }

}

I have tried all kinds of variations with the camel casing but nothing seems to work. Thanks in advance for the help.

1 Answer 1

0

I don't know why i find out my solution every time i post some problem here but i'm happy to share.

The problem was that the class TIG_Buckaroo3Extended_Model_PaymentMethods_PaymentMethod

already was overridden by for example: TIG_Buckaroo3Extended_Model_PaymentMethods_Ideal_PaymentMethod

Every payment method within this module overrides this class making it a real pain to rewrite it all. I have to make files/folders for each payment method in order to rewrite it and i have to add rewrite instructions to my config.xml for each method like so:

<buckaroo3extended>
            <rewrite>
                <paymentMethods_ideal_paymentMethod>Mycompany_PaymentRestriction_Model_PaymentMethods_Ideal_PaymentMethod</paymentMethods_ideal_paymentMethod>
            </rewrite>
        </buckaroo3extended>

So the lessons learned from this: Check if the thing you wan't to rewrite isn't already overridden by something else. If it is overridden, rewrite the thing at the end of the rewrite chain.

Hope i save someone some headaches :)

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.