Home » Magento tutorials » How to filter payment method in one page checkout?

How to filter payment method in one page checkout?

There are several way to filter payment method in one page checkout:

  • By overriding template: app/design/frontend/[interface]/[theme]/template/checkout/onepage/payment/methods.phtml
  • By overriding method: Mage_Checkout_Block_Onepage_Payment_Methods::_canUseMethod()
  •  By overriding method: Mage_Payment_Model_Method_Abstract::isAvailable()
  •  By overriding method: Mage_Checkout_Block_Onepage_Payment_Methods::getMethods()
  •  By observing event: payment_method_is_active
Among above methods obviously using event-observer technique is the best way to go.
And here I will be discussing about how to enable the PayPal (Website Standard) method only when current currency is USD.
Suppose a skeleton module(MagePsycho_Paymentfilter) has already been created.

Step 1: 

 Register the event: ‘payment_method_is_active’ in config.xml.
Add the following xml code in app/code/local/MagePsycho/Paymentfilter/etc/config.xml:

Step 2: Implement the observer model

Create observer file: app/code/local/MagePsycho/Paymentfilter/Model/Observer.php and paste the following code:

Step 3: 

Go ahead for testing.

About Gareth

Gareth is an editor at Tutorial Magento. His special hobby is to share magento knowledge and experience with everyone.

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

Scroll To Top