0

I'd like to add in some rules for the 'Payment Information' section of the Magento Onepage Checkout.

Currently my site will show the options:

  • Debit/Credit Card
  • PayPal
  • Invoice Organisation

I'd like to only show the 'Invoice' option if they have selected a particular option within the Billing Payment section.

Which file should I edit to access the options within the Payment Section on the onepage checkout? Can anyone point me in the right direction?

3

Theres a really handy event for disabling and enabling payment methods on the fly.

Add the following into your config.xml section

<payment_method_is_active>
    <observers>
        <preorder_payment>
            <class>your_module/observers</class>
            <method>invoiceOnly</method>
        </preorder_payment>
    </observers>
</payment_method_is_active>

Then create the following function in your observer.php

/**
 * Disable all other payments
 * @param Varien_Event_Observer $observer
 */
public function invoiceOnly(Varien_Event_Observer $observer) {

    $_result = $observer->getResult();
    $_methodInstance = $observer->getMethodInstance();

    if(BILLING_CONDITION_HERE) {
        if($_methodInstance->getCode() != 'METHOD_CODE') {
            $_result->isAvailable = false;
        } else {
            $_result->isAvailable = true;
        }
    }

}

You'll need to modify the BILLING_CONDITION_HERE and the METHOD_CODE (to the invoice payment method code)

This will automatically disable everything except METHOD_CODE if the billing condition is met.

3
  • Dave... awesome :)
    – Zabs
    Jul 4 '14 at 14:59
  • @Zabs no problem :)
    – Dave
    Jul 4 '14 at 15:14
  • Thank you. It works fine for my custom logic as well. However, I've got a question about controller_action_postdispatch_checkout_onepage_saveBilling event, which is fired after payment_method_is_active. It's problematic because I'm trying to enable/disable some payment methods depending of user address. Do you have an idea which event should I use after address is saved and before payment methods are displayed?
    – DarkCowboy
    Jun 13 '17 at 8:24
1

you can disable

Paypal Payment module

From

Admin->system->configure->Payment Methods->Paypal

Similarly You can disable credit card from admin:

Admin->system->configure->Saved CC

and select disable option.

1
  • 2
    The OP is looking to disable payment options depending on user input. This would disable the option entirely.
    – Dave
    Jul 4 '14 at 13:31

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.